diff --git a/src/aimeio.c b/src/aimeio.c index c17252b..137d47a 100644 --- a/src/aimeio.c +++ b/src/aimeio.c @@ -139,7 +139,7 @@ static unsigned int __stdcall aime_io_poll_thread_proc(void *ctx) printf("DEBUG: aime_io_poll_thread_proc(). \r\n"); while (!READER_POLL_STOP_FLAG) { - if (card_data.card_type != 0) // Halting polling once a card is found, waiting for the game to read it's value. + if (card_data.card_type == 0) // Halting polling once a card is found, waiting for the game to read it's value. scard_poll(&card_data); // We're trying to find a card. If we do, the card's id and type are written to card_data. } @@ -201,7 +201,7 @@ HRESULT aime_io_nfc_poll(uint8_t unit_no) return S_OK; // Don't do anything more if the scan key is not held - if (GetAsyncKeyState(aime_io_cfg.vk_scan) & 0x8000) + if (!(GetAsyncKeyState(aime_io_cfg.vk_scan) & 0x8000)) return S_OK; // Set which card we want to read (we will read the x'th line in the card's file, x being determined by which key is pressed on the keypad). @@ -278,7 +278,7 @@ HRESULT aime_io_nfc_get_felica_id(uint8_t unit_no, uint64_t *IDm) val = (val << 8) | card_data.card_id[i]; *IDm = val; - printf("aime_io_nfc_get_felica_id: Sending FeliCa card with IDm %02X%02X %02X%02X %02X%02X %02X%02X\r\n", card_data.card_id[0], card_data.card_id[1], card_data.card_id[2], card_data.card_id[3], card_data.card_id[4], card_data.card_id[5], card_data.card_id[6], card_data.card_id[7]); + printf("aime_io_nfc_get_felica_id: Sending FeliCa card with serial %02X%02X %02X%02X %02X%02X %02X%02X\r\n", card_data.card_id[0], card_data.card_id[1], card_data.card_id[2], card_data.card_id[3], card_data.card_id[4], card_data.card_id[5], card_data.card_id[6], card_data.card_id[7]); memset(&card_data, 0, sizeof(card_data)); // Reset card_data structure return S_OK; diff --git a/src/aimetest.c b/src/aimetest.c index c94b8c2..660936b 100644 --- a/src/aimetest.c +++ b/src/aimetest.c @@ -51,17 +51,12 @@ int main() if (aime_io_nfc_get_felica_id(0, &IDm) == S_OK) { // aime_io_led_set_color(0, 0, 255, 0); - printf("AIMETEST: Found FeliCa card with uid %llx\r\n\n", IDm); + printf("AIMETEST: Found FeliCa card with IDm %llx\r\n\n", IDm); } if (aime_io_nfc_get_aime_id(0, luid, 10) == S_OK) { // aime_io_led_set_color(0, 0, 0, 255); - printf("AIMETEST: Found old card with uid "); - for (int i = 0; i < 10; i++) - { - printf("%02x ", luid[i]); - } - printf("\r\n\n"); + printf("AIMETEST: Found old card with luID %02X%02X %02X%02X %02X%02X %02X%02X %02X%02X\r\n", luid[0], luid[1], luid[2], luid[3], luid[4], luid[5], luid[6], luid[7], luid[8], luid[9]); } Sleep(500); // printf("poll ok but no card?!\r\n"); diff --git a/src/scard/scard.c b/src/scard/scard.c index bff099b..f276cdb 100644 --- a/src/scard/scard.c +++ b/src/scard/scard.c @@ -107,16 +107,10 @@ bool scard_init(struct aime_io_config config) if ((lRet = SCardDisconnect(hCard, SCARD_LEAVE_CARD)) != SCARD_S_SUCCESS) printf("scard_init: Failed SCardDisconnect : 0x%08X\n", lRet); - // Extract the relevant names from the multi-string. - readerNameLen = lstrlen(reader_list); - reader_name = (LPTSTR)HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(TCHAR) * (readerNameLen + 1)); - memcpy(reader_name, &reader_list, (size_t)(readerNameLen + 1)); - - if (reader_name) - printf("scard_init: Using reader : %s\n", reader_name); + printf("scard_init: Using reader : %s\n", reader_list); memset(&reader_state, 0, sizeof(SCARD_READERSTATE)); - reader_state.szReader = reader_name; + reader_state.szReader = reader_list; return TRUE; default: @@ -208,8 +202,6 @@ void scard_update(struct card_data *card_data, SCARDCONTEXT _hContext, LPCTSTR _ return; } - printf("scard_update: atr Return: len(%zu) = %02x (%08X)\n", sizeof(cByteAtr), (unsigned int)atr, cByteAtr); - BYTE cardProtocol = atr[12]; if (cardProtocol == SCARD_ATR_PROTOCOL_ISO14443_PART3) { @@ -245,7 +237,7 @@ void scard_update(struct card_data *card_data, SCARDCONTEXT _hContext, LPCTSTR _ memset(&pbRecv[cbRecv], 0, 8 - cbRecv); } else if (cbRecv > 8) - printf("scard_update: taking first 8 bytes of len(uid) = %02X\n", cbRecv); + printf("scard_update: taking first 8 bytes of %d received\n", cbRecv); memcpy(card_data->card_id, pbRecv, 8); }