~stephen-tiedemann/nfcpy/0.10

« back to all changes in this revision

Viewing changes to nfc/clf/rcs380.py

  • Committer: stephen.tiedemann at gmail
  • Date: 2015-07-20 09:15:45 UTC
  • Revision ID: stephen.tiedemann@gmail.com-20150720091545-fpv270zya1guhtvg
fix: RC-S380 driver reactivated TT2 CRC_A hardware check in send routine but the check must be done in software

Show diffs side-by-side

added added

removed removed

Lines of Context:
412
412
                    if sel_res[0] & 0b00000100: uid = uid + sdd_res[1:4]
413
413
                    else: uid = uid + sdd_res[0:4]; break
414
414
            if sel_res[0] & 0b00000100 == 0:
415
 
                if sel_res[0] & 0b01100000 == 0:
416
 
                    # For Type 2 Tags we must check CRC in software
417
 
                    # to be able to receive ACK/NAK responses.
418
 
                    self.chipset.in_set_protocol(check_crc=0)
419
415
                return nfc.clf.RemoteTarget(target.brty, sens_res=sens_res,
420
416
                                            sel_res=sel_res, sdd_res=uid)
421
417
        except CommunicationError as error:
826
822
        timeout_msec = min(int(timeout * 1000), 0xFFFF) if timeout else 0
827
823
        self.chipset.in_set_rf(target.brty_send, target.brty_recv)
828
824
        self.chipset.in_set_protocol(self.chipset.in_set_protocol_defaults)
829
 
        self.chipset.in_set_protocol(
830
 
            add_parity=1 if target.brty_send.endswith('A') else 0,
831
 
            check_parity=1 if target.brty_recv.endswith('A') else 0)
 
825
        in_set_protocol_settings = {
 
826
            'add_parity': 1 if target.brty_send.endswith('A') else 0,
 
827
            'check_parity': 1 if target.brty_recv.endswith('A') else 0
 
828
        }
832
829
        try:
833
830
            if (target.brty == '106A' and target.sel_res and
834
831
                target.sel_res[0] & 0x60 == 0x00):
 
832
                # Driver must check TT2 CRC to get ACK/NAK
 
833
                in_set_protocol_settings['check_crc'] = 0
 
834
                self.chipset.in_set_protocol(**in_set_protocol_settings)
835
835
                return self._tt2_send_cmd_recv_rsp(data, timeout_msec)
836
836
            else:
 
837
                self.chipset.in_set_protocol(**in_set_protocol_settings)
837
838
                return self.chipset.in_comm_rf(data, timeout_msec)
838
839
        except CommunicationError as error:
839
840
            log.debug(error)
844
845
    def _tt2_send_cmd_recv_rsp(self, data, timeout_msec):
845
846
        # The Type2Tag implementation needs to receive the Mifare
846
847
        # ACK/NAK responses but the chipset reports them as crc error
847
 
        # (indistinguishable from a real crc error). We thus have to
 
848
        # (indistinguishable from a real crc error). We thus had to
848
849
        # switch off the crc check and do it here.
849
850
        data = self.chipset.in_comm_rf(data, timeout_msec)
850
851
        if len(data) > 2 and self.check_crc_a(data) is False: