コード例 #1
0
 def run(self):
     cmd = CommandType.REQA
     struct = CommandStructure.encode_command(cmd, [])
     s = self._tag
     ns = self._reader
     i = 0
     mx = self._max
     while i < mx or mx == 0:
         ret = s.process_packet(cmd, struct)
         if not ret:
             cmd = CommandType.REQA
             struct = CommandStructure.encode_command(cmd, [])
             s = self._tag
             ns = self._reader
             s.wake_up()  # so that it can respond
             i += 1
         else:
             cmd, struct = ret
             temp = s
             s = ns
             ns = temp
コード例 #2
0
ファイル: usrp_nfc.py プロジェクト: drtyhlpr/usrp_nfc
 def run(self):
     cmd = CommandType.REQA
     struct = CommandStructure.encode_command(cmd, [])
     s = self._tag
     ns = self._reader
     i = 0
     mx = self._max
     while i < mx or mx == 0:
         ret = s.process_packet(cmd, struct)
         if not ret:
             cmd = CommandType.REQA
             struct = CommandStructure.encode_command(cmd, [])
             s = self._tag
             ns = self._reader 
             s.wake_up() # so that it can respond
             i += 1
         else:
             cmd, struct = ret
             temp = s
             s = ns
             ns = temp 
コード例 #3
0
    def _handle_next(self, cmd, extra):
        if not cmd:
            return None
        struct = CommandStructure.encode_command(cmd, extra)
        print "TAG OUTGOING"
        struct.display()

        all_bits = Convert.to_bit_ar(struct.all_bytes(), True)
        if self._encode:
            all_bits = self._encode(all_bits, cmd)
        #print all_bits
        self._callback(all_bits)
        return (cmd, struct)
コード例 #4
0
ファイル: tag.py プロジェクト: drtyhlpr/usrp_nfc
    def _handle_next(self, cmd, extra):
        if not cmd:
            return None
        struct = CommandStructure.encode_command(cmd, extra)
        print "TAG OUTGOING"
        struct.display()

        all_bits = Convert.to_bit_ar(struct.all_bytes(), True)
        if self._encode:
            all_bits = self._encode(all_bits, cmd)   
        #print all_bits
        self._callback(all_bits)
        return (cmd, struct)
コード例 #5
0
ファイル: reader.py プロジェクト: drtyhlpr/usrp_nfc
    def _handle_next(self, cmd, extra):
        struct = CommandStructure.encode_command(cmd, extra)
        print "READER OUTGOING"
        struct.display()
        if cmd == CommandType.HALT:
           self._reset_tag()

        all_bits = Convert.to_bit_ar(struct.all_bytes(), True)
        if self._encode:
            all_bits = self._encode(all_bits, cmd)   
        #print all_bits
        self._callback(all_bits, cmd == CommandType.HALT)
        return (cmd, struct) 
コード例 #6
0
ファイル: reader.py プロジェクト: yqq836438958/usrp_nfc
    def _handle_next(self, cmd, extra):
        struct = CommandStructure.encode_command(cmd, extra)
        print "READER OUTGOING"
        struct.display()
        if cmd == CommandType.HALT:
            self._reset_tag()

        all_bits = Convert.to_bit_ar(struct.all_bytes(), True)
        if self._encode:
            all_bits = self._encode(all_bits, cmd)
        #print all_bits
        self._callback(all_bits, cmd == CommandType.HALT)
        return (cmd, struct)
コード例 #7
0
ファイル: fsm.py プロジェクト: 5ch4um1/usrp_nfc
    def process_bits(self, bits, packet_type):
        bits = self._fix_ending(bits, packet_type)

        bits = self._decrypt_bits(bits)
        
        bytes = self._check_parity(bits)

        if not bytes:
            print ("PARITY ERROR")
            return
        
        prev_cmd = self._cur_cmd
        cmd = CommandType.get_command_type(bytes, packet_type, prev_cmd)

        if cmd:
            self._cur_cmd = cmd

        c = CommandStructure.decode_command(cmd, bytes)
        self.process_command(cmd, c)
        self._callback(cmd, c)
コード例 #8
0
ファイル: fsm.py プロジェクト: drtyhlpr/usrp_nfc
    def process_bits(self, bits, packet_type):
        bits = self._fix_ending(bits, packet_type)

        bits = self._decrypt_bits(bits)
        
        bytes = self._check_parity(bits)

        if not bytes:
            print "PARITY ERROR"
            return
        
        prev_cmd = self._cur_cmd
        cmd = CommandType.get_command_type(bytes, packet_type, prev_cmd)

        if cmd:
            self._cur_cmd = cmd

        c = CommandStructure.decode_command(cmd, bytes)
        self.process_command(cmd, c)
        self._callback(cmd, c)