Page 581 - 3-2
P. 581

self.Write_MFRC522(self.CommandReg, self.PCD_CALCCRC)
                i = 0xFF
                while True:
                  n = self.Read_MFRC522(self.DivIrqReg)
                  i = i - 1
                  if not ((i != 0) and not (n&0x04)):
                    break
                pOutData = []
                pOutData.append(self.Read_MFRC522(self.CRCResultRegL))
                pOutData.append(self.Read_MFRC522(self.CRCResultRegM))
                return pOutData


              def MFRC522_SelectTag(self, serNum):
                backData = []
                buf = []
                buf.append(self.PICC_SElECTTAG)
                buf.append(0x70)
                i = 0
                while i<5:
                  buf.append(serNum[i])
                  i = i + 1
                pOut = self.CalulateCRC(buf)
                buf.append(pOut[0])
                buf.append(pOut[1])
                (status, backData, backLen) = self.MFRC522_ToCard(self.PCD_TRANSCEIVE, buf)


                if (status == self.MI_OK) and (backLen == 0x18):
                  print "Size: " + str(backData[0])
                  return    backData[0]
                else:
                  return 0


              def MFRC522_Auth(self, authMode, BlockAddr, Sectorkey, serNum):
                buff = []
                # First byte should be the authMode (A or B)
                buff.append(authMode)
                # Second byte is the trailerBlock (usually 7)
                buff.append(BlockAddr)
                # Now we need to append the authKey which usually is 6 bytes of 0xFF
                i = 0
                while(i < len(Sectorkey)):
                  buff.append(Sectorkey[i])
                  i = i + 1
                i = 0
                # Next we append the first 4 bytes of the UID


                                                         - 581 -
   576   577   578   579   580   581   582   583   584   585   586