def readMifare(self): result = ci2c.write(CFG_ADDRESS, [1, CMD_SELECT_MIFARE]) time.sleep(WR_RD_DELAY) if result != 0: error("readMifare:Cannot read, result=" + str(result)) return False result, buf = ci2c.read(CFG_ADDRESS, 15) if result != 0: error("readMifare:Cannot write, result=" + str(result)) return False length = buf[0] cmd = buf[1] status = buf[2] if (status != 0x00): self.uid = None self.type = None return False # uid length varies on type, and type is after uuid uid = buf[3:length] type = buf[length] self.type = type self.uid = uid return True
def readMifare(self): #ci2c.initDefaults() #time.sleep(1) #self.GPIO.setup(26, GPIO.OUT) #self.GPIO.output(26, GPIO.LOW) result = ci2c.write(CFG_ADDRESS, [1, CMD_SELECT_MIFARE]) time.sleep(WR_RD_DELAY) if result != 0: error("readMifare:Cannot write, result=" + str(result)) ci2c.relase() return False result, buf = ci2c.read(CFG_ADDRESS, 15) if result != 0: error("readMifare:Cannot read, result=" + str(result)) ci2c.relase() return False length = buf[0] cmd = buf[1] status = buf[2] ci2c.relase() #self.GPIO.output(26, GPIO.HIGH) #self.GPIO.cleanup() if (status != 0x00): self.uid = None self.type = None return False # uid length varies on type, and type is after uuid uid = buf[3:length] type = buf[length] self.type = type self.uid = uid return True
def getFirmware(self): # Tx ADDRESS, 1, CMD_GET_FIRMWARE result = ci2c.write(CFG_ADDRESS, [1, CMD_GET_FIRMWARE]) time.sleep(WR_RD_DELAY) if result != 0: error("getFirmware:Cannot read, result=" + str(result)) return None result, buf = ci2c.read(CFG_ADDRESS, 15) if result != 0: error("getFirmware:Cannot write, result=" + str(result)) return None ver = buf[3:] self.validateVer(ver) return self.tostr(ver)