def test_get_status(C): status_st = ffi.new('struct NK_status *') if not status_st: raise Exception("Could not allocate status") err = C.NK_get_status(status_st) assert err == 0 assert status_st.firmware_version_major == 0 assert status_st.firmware_version_minor != 0
def random(C): data = ffi.new('struct GetRandom_t *') req_count = 50 res = C.NK_get_random(req_count, data) assert res == DeviceErrorCode.STATUS_OK assert C.NK_get_last_command_status() == DeviceErrorCode.STATUS_OK assert data.op_success == 1 assert data.size_effective == req_count
def test_struct_multiline_prodtest(C): info_st = ffi.new('struct NK_storage_ProductionTest *') if info_st is None: raise Exception('Invalid value') err = C.NK_get_storage_production_info(info_st) assert err == 0 assert info_st.SD_Card_ManufacturingYear_u8 != 0 assert info_st.SD_Card_ManufacturingMonth_u8 != 0 assert info_st.SD_Card_Size_u8 != 0 assert info_st.FirmwareVersion_au8[0] == 0 assert info_st.FirmwareVersion_au8[1] >= 50 info = 'CPU:{CPU},SC:{SC},SD:{SD},' \ 'SCM:{SCM},SCO:{SCO},DAT:{DAT},Size:{size},Firmware:{fw} - {fwb}'.format( CPU='0x{:08x}'.format(info_st.CPU_CardID_u32), SC='0x{:08x}'.format(info_st.SmartCardID_u32), SD='0x{:08x}'.format(info_st.SD_CardID_u32), SCM='0x{:02x}'.format(info_st.SD_Card_Manufacturer_u8), SCO='0x{:04x}'.format(info_st.SD_Card_OEM_u16), DAT='20{}.{}'.format(info_st.SD_Card_ManufacturingYear_u8, info_st.SD_Card_ManufacturingMonth_u8), size=info_st.SD_Card_Size_u8, fw='{}.{}'.format(info_st.FirmwareVersion_au8[0], info_st.FirmwareVersion_au8[1]), fwb=info_st.FirmwareVersionInternal_u8 ) print(info)