diff --git a/src/examples/nfc-list.c b/src/examples/nfc-list.c index abd48c1..d83fabf 100644 --- a/src/examples/nfc-list.c +++ b/src/examples/nfc-list.c @@ -45,7 +45,7 @@ static byte_t abtFelica[5] = { 0x00, 0xff, 0xff, 0x00, 0x00 }; int main(int argc, const char* argv[]) { size_t szFound; - int i; + size_t i; nfc_target_info_t nti; nfc_device_desc_t *pnddDevices; diff --git a/src/examples/nfc-mfclassic.c b/src/examples/nfc-mfclassic.c index 567586f..12df8a6 100644 --- a/src/examples/nfc-mfclassic.c +++ b/src/examples/nfc-mfclassic.c @@ -338,6 +338,7 @@ int main(int argc, const char* argv[]) byte_t* pbtUID; FILE* pfKeys = NULL; FILE* pfDump = NULL; + const char* command = argv[1]; if(argc < 2) { @@ -345,7 +346,6 @@ int main(int argc, const char* argv[]) exit(EXIT_FAILURE); } - const char* command = argv[1]; if(strcmp(command, "r") == 0) { atAction = ACTION_READ; diff --git a/src/lib/bitutils.c b/src/lib/bitutils.c index 244f1c9..119c36f 100644 --- a/src/lib/bitutils.c +++ b/src/lib/bitutils.c @@ -152,6 +152,7 @@ void print_hex(const byte_t* pbtData, const size_t szBytes) void print_hex_bits(const byte_t* pbtData, const size_t szBits) { + uint8_t uRemainder; size_t szPos; size_t szBytes = szBits/8; @@ -160,7 +161,7 @@ void print_hex_bits(const byte_t* pbtData, const size_t szBits) printf("%02x ",pbtData[szPos]); } - uint8_t uRemainder = szBits % 8; + uRemainder = szBits % 8; // Print the rest bits if (uRemainder != 0) { @@ -174,6 +175,7 @@ void print_hex_bits(const byte_t* pbtData, const size_t szBits) void print_hex_par(const byte_t* pbtData, const size_t szBits, const byte_t* pbtDataPar) { + uint8_t uRemainder; size_t szPos; size_t szBytes = szBits/8; @@ -188,7 +190,7 @@ void print_hex_par(const byte_t* pbtData, const size_t szBits, const byte_t* pbt } } - uint8_t uRemainder = szBits % 8; + uRemainder = szBits % 8; // Print the rest bits, these cannot have parity bit if (uRemainder != 0) { diff --git a/src/lib/buses/uart.c b/src/lib/buses/uart.c index 1f7f0d7..0b74eee 100644 --- a/src/lib/buses/uart.c +++ b/src/lib/buses/uart.c @@ -369,9 +369,10 @@ uint32_t uart_get_speed(const serial_port sp) bool uart_cts(const serial_port sp) { - char status; - if (ioctl(((serial_port_unix*)sp)->fd,TIOCMGET,&status) < 0) return false; - return (status & TIOCM_CTS); + DWORD ModemStat; + const serial_port_windows* spw = (serial_port_windows*)sp; + if (!GetCommModemStatus(spw->hPort,&ModemStat)) return false; + return (ModemStat & MS_CTS_ON); } bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen) diff --git a/src/lib/drivers/acr122.c b/src/lib/drivers/acr122.c index 69c188d..a2fa068 100644 --- a/src/lib/drivers/acr122.c +++ b/src/lib/drivers/acr122.c @@ -56,8 +56,9 @@ #define ACR122_RESPONSE_LEN 268 const char *supported_devices[] = { - "ACS ACR122U", + "ACS ACR122", "ACS ACR 38U-CCID", + " CCID USB", NULL }; @@ -135,6 +136,8 @@ acr122_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_t *p size_t szDeviceNamesLen = sizeof(acDeviceNames); uint32_t uiBusIndex = 0; SCARDCONTEXT *pscc; + bool bSupported; + int i; // Clear the reader list memset(acDeviceNames, '\0', szDeviceNamesLen); @@ -158,8 +161,8 @@ acr122_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_t *p DBG("- %s (pos=%d)", acDeviceNames + szPos, szPos); - bool bSupported = false; - for (int i = 0; supported_devices[i] && !bSupported; i++) { + bSupported = false; + for (i = 0; supported_devices[i] && !bSupported; i++) { int l = strlen(supported_devices[i]); bSupported = 0 == strncmp(supported_devices[i], acDeviceNames + szPos, l); } diff --git a/src/lib/drivers/pn532_uart.c b/src/lib/drivers/pn532_uart.c index 4ba7f60..f8423ff 100644 --- a/src/lib/drivers/pn532_uart.c +++ b/src/lib/drivers/pn532_uart.c @@ -37,6 +37,8 @@ #ifdef _WIN32 #define SERIAL_STRING "COM" + #define snprintf _snprintf + #define strdup _strdup #else // unistd.h is needed for usleep() fct. #include @@ -80,6 +82,10 @@ pn532_uart_pick_device (void) bool pn532_uart_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_t *pszDeviceFound) { + serial_port sp; + char acConnect[BUFFER_LENGTH]; + int iDevice; + /* @note: Due to UART bus we can't know if its really a pn532 without * sending some PN53x commands. But using this way to probe devices, we can * have serious problem with other device on this bus */ @@ -89,12 +95,9 @@ pn532_uart_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_ INFO("Sorry, serial auto-probing have been disabled at compile time."); return false; #else /* DISABLE_SERIAL_AUTOPROBE */ - char acConnect[BUFFER_LENGTH]; - serial_port sp; - // I have no idea how MAC OS X deals with multiple devices, so a quick workaround - for (int iDevice=0; iDeviceuiSpeed); } - /** @info PN532C106 wakeup. */ - /** @todo Put this command in pn53x init process */ - byte_t abtRxBuf[BUFFER_LENGTH]; - size_t szRxBufLen; - const byte_t pncmd_pn532c106_wakeup[] = { 0x55,0x55,0x00,0x00,0x00,0x00,0x00,0xFF,0x03,0xFD,0xD4,0x14,0x01,0x17,0x00 }; - uart_send(sp, pncmd_pn532c106_wakeup, sizeof(pncmd_pn532c106_wakeup)); if (!uart_receive(sp,abtRxBuf,&szRxBufLen)) { diff --git a/src/lib/nfc.c b/src/lib/nfc.c index 4cbfba3..156e55b 100644 --- a/src/lib/nfc.c +++ b/src/lib/nfc.c @@ -24,6 +24,7 @@ */ #include +#include #include #include @@ -34,7 +35,9 @@ #include -#include "../../config.h" +#ifndef _WIN32 + #include "../../config.h" +#endif // _WIN32 nfc_device_desc_t * nfc_pick_device (void); @@ -94,6 +97,7 @@ void nfc_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_t *pszDeviceFound) { uint32_t uiDriver; + size_t szN; *pszDeviceFound = 0; @@ -102,7 +106,7 @@ nfc_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_t *pszD if (drivers_callbacks_list[uiDriver].list_devices != NULL) { DBG("List avaible device using %s driver",drivers_callbacks_list[uiDriver].acDriver); - size_t szN = 0; + szN = 0; if (drivers_callbacks_list[uiDriver].list_devices (pnddDevices + (*pszDeviceFound), szDevices - (*pszDeviceFound), &szN)) { *pszDeviceFound += szN;