Example #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
Example #2
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 
Example #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)
Example #4
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)
Example #5
0
    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) 
Example #6
0
    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)
Example #7
0
    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)
Example #8
0
    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)