def selectType(TYPE = TYPE_AUTO): if TYPE < 0 or TYPE > 0xD: raise apduBuilderException("invalid argument TYPE, a value between 0 and 13 was expected, got "+str(TYPE)) apdu = ApduDefault(cla=0xFF,ins=0xA4,p1=0x00,p2=0x00,data=[TYPE]) apdu.removeExpectedAnswer() return apdu
def I2C_selectPageSize(page_size = I2C_PAGE_SIZE_8BYTES): if page_size < 0x03 or page_size > 0x0A: raise apduBuilderException("invalid argument page_size, a value between 0x03 and 0x07 was expected, got "+str(page_size)) apdu = ApduDefault(cla=0xFF,ins=0x01,p1=0x00,p2=0x00, data=(page_size,)) apdu.removeExpectedAnswer() return apdu
def SLE_checkPinCode(pinBytes): if len(pinBytes) < 2 or len(pinBytes) > 3: raise apduBuilderException("invalid argument pinBytes, a list of bytes of lenght 2 or 3 was expected, got "+str(len(pinBytes))) apdu = ApduDefault(cla=0xFF,ins=0x20,p1=0x00,p2=0x00, data=pinBytes) apdu.removeExpectedAnswer() return apdu
def write(adress, datas, area = WRITE_AREA_0): if adress < 0 or adress > 0x1ffff: raise apduBuilderException("invalid argument adress, a value between 0 and 1023 was expected, got "+str(TYPE)) if len(datas) < 1 or len(datas) > 255: raise apduBuilderException("invalid datas size, must be a list from 1 to 255 item, got "+str(len(datas))) if area < 0xd0 or area > 0xd4: raise apduBuilderException("invalid argument area, a value between 0xd0 and 0xd4 was expected, got "+str(area)) if adress >= 0x10000: area |= 0x1 msb = (adress >> 8) & 0xFF lsb = adress & 0xFF apdu = ApduDefault(cla=0xFF,ins=area,p1=msb,p2=lsb, data=datas) apdu.removeExpectedAnswer() return apdu