|
|
@ -8,9 +8,9 @@ |
|
|
|
using namespace std; |
|
|
|
using namespace iflytop; |
|
|
|
|
|
|
|
#define SECTOR_SIZE (64)
|
|
|
|
#define SECTOR_NUM (4 * 8)
|
|
|
|
#define MAX_SIZE (SECTOR_SIZE * SECTOR_NUM)// 2k
|
|
|
|
#define SECTOR_SIZE (128)
|
|
|
|
#define SECTOR_NUM (2 * 8)
|
|
|
|
#define MAX_SIZE (SECTOR_SIZE * SECTOR_NUM) // 2k
|
|
|
|
|
|
|
|
#define TAG "EEPROMService"
|
|
|
|
|
|
|
@ -139,6 +139,7 @@ void EEPROMService::detect_online() { |
|
|
|
* |
|
|
|
*/ |
|
|
|
|
|
|
|
memset(m_idcardcache, 0, MAX_SIZE); |
|
|
|
for (uint16_t i = 0; i < SECTOR_NUM; i++) { |
|
|
|
int32_t len = SECTOR_SIZE; |
|
|
|
int32_t suc = m_nowonline->read(i * SECTOR_SIZE, m_idcardcache + i * SECTOR_SIZE, &len); |
|
|
@ -164,10 +165,17 @@ int32_t EEPROMService::a8000_idcard_reader_read_raw(int32_t index, uint8_t* data |
|
|
|
zlock_guard guard(m_mutex); |
|
|
|
if (!m_nowonline) return err::kdevice_offline; |
|
|
|
if (*len < SECTOR_SIZE) return err::kbuffer_not_enough; |
|
|
|
ZLOGI(TAG, "read: %d", index); |
|
|
|
|
|
|
|
uint16_t add = index * SECTOR_SIZE; |
|
|
|
*len = SECTOR_SIZE; |
|
|
|
|
|
|
|
if (add >= MAX_SIZE) { |
|
|
|
*len = 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
memcpy(data, m_idcardcache + add, *len); |
|
|
|
return 0; |
|
|
|
} |
|
|
|