windows port improved:
- PCSC headers/libs are not a requierement sif you dont select ACR122 driver - uart_win32 implementation now handles timeouts
This commit is contained in:
parent
d286a3c4b7
commit
b2666dea15
5 changed files with 40 additions and 17 deletions
|
@ -88,6 +88,16 @@ IF(NOT WIN32)
|
|||
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
ENDIF(NOT WIN32)
|
||||
|
||||
IF(PCSC_INCLUDE_DIRS)
|
||||
INCLUDE_DIRECTORIES(${PCSC_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${PCSC_LIBRARY_DIRS})
|
||||
ENDIF(PCSC_INCLUDE_DIRS)
|
||||
|
||||
IF(LIBUSB_INCLUDE_DIRS)
|
||||
INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${LIBUSB_LIBRARY_DIRS})
|
||||
ENDIF(LIBUSB_INCLUDE_DIRS)
|
||||
|
||||
ADD_SUBDIRECTORY(libnfc)
|
||||
ADD_SUBDIRECTORY(include)
|
||||
ADD_SUBDIRECTORY(utils)
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
SET(EXAMPLES-SOURCES nfc-anticol nfc-dep-initiator nfc-dep-target nfc-emulate-tag nfc-emulate-uid nfc-poll nfc-relay pn53x-diagnose pn53x-sam pn53x-tamashell)
|
||||
SET(EXAMPLES-SOURCES nfc-anticol nfc-dep-initiator nfc-dep-target nfc-emulate-tag nfc-emulate-uid nfc-poll nfc-relay)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libnfc)
|
||||
|
||||
INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS} ${PCSC_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${LIBUSB_LIBRARY_DIRS} ${PCSC_LIBRARY_DIRS})
|
||||
|
||||
# Examples
|
||||
FOREACH(source ${EXAMPLES-SOURCES})
|
||||
ADD_EXECUTABLE(${source} ${source}.c)
|
||||
|
|
|
@ -14,14 +14,29 @@ ENDIF(LIBNFC_SERIAL_AUTOPROBE_ENABLED)
|
|||
|
||||
INCLUDE(LibnfcDrivers)
|
||||
|
||||
INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS} ${PCSC_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${LIBUSB_LIBRARY_DIRS} ${PCSC_LIBRARY_DIRS})
|
||||
IF(PCSC_INCLUDE_DIRS)
|
||||
INCLUDE_DIRECTORIES(${PCSC_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${PCSC_LIBRARY_DIRS})
|
||||
ENDIF(PCSC_INCLUDE_DIRS)
|
||||
|
||||
IF(LIBUSB_INCLUDE_DIRS)
|
||||
INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${LIBUSB_LIBRARY_DIRS})
|
||||
ENDIF(LIBUSB_INCLUDE_DIRS)
|
||||
|
||||
# Library
|
||||
SET(LIBRARY_SOURCES nfc nfc-device nfc-emulation iso14443-subr mirror-subr ${DRIVERS_SOURCES} ${BUSES_SOURCES} ${CHIPS_SOURCES})
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
ADD_LIBRARY(nfc SHARED ${LIBRARY_SOURCES})
|
||||
TARGET_LINK_LIBRARIES(nfc ${LIBUSB_LIBRARIES} ${PCSC_LIBRARIES})
|
||||
|
||||
IF(PCSC_INCLUDE_DIRS)
|
||||
TARGET_LINK_LIBRARIES(nfc ${PCSC_LIBRARIES})
|
||||
ENDIF(PCSC_INCLUDE_DIRS)
|
||||
|
||||
IF(LIBUSB_INCLUDE_DIRS)
|
||||
TARGET_LINK_LIBRARIES(nfc ${LIBUSB_LIBRARIES})
|
||||
ENDIF(LIBUSB_INCLUDE_DIRS)
|
||||
|
||||
IF(WIN32)
|
||||
TARGET_LINK_LIBRARIES(nfc wsock32)
|
||||
ENDIF(WIN32)
|
||||
|
|
|
@ -147,23 +147,25 @@ uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, void * abort_p,
|
|||
BOOL res;
|
||||
|
||||
// XXX Put this part into uart_win32_timeouts () ?
|
||||
DWORD timeout_ms = timeout ? ((timeout->tv_sec * 1000) + (timeout->tv_usec / 1000)) : 0;
|
||||
COMMTIMEOUTS timeouts;
|
||||
timeouts.ReadIntervalTimeout = 0;
|
||||
timeouts.ReadTotalTimeoutMultiplier = 0;
|
||||
timeouts.ReadTotalTimeoutConstant = timeout ? ((timeout->tv_sec * 1000) + (timeout->tv_usec / 1000)) : 0;
|
||||
timeouts.ReadTotalTimeoutConstant = timeout_ms;
|
||||
timeouts.WriteTotalTimeoutMultiplier = 0;
|
||||
timeouts.WriteTotalTimeoutConstant = timeout ? ((timeout->tv_sec * 1000) + (timeout->tv_usec / 1000)) : 0;
|
||||
timeouts.WriteTotalTimeoutConstant = timeout_ms;
|
||||
|
||||
if (!SetCommTimeouts (((serial_port_windows *) sp)->hPort, &timeouts)) {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Unable to apply new timeout settings.");
|
||||
return ECOMIO;
|
||||
}
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Timeouts are set to %u ms", timeout_ms);
|
||||
|
||||
// TODO Enhance the reception method
|
||||
// - According to MSDN, it could be better to implement nfc_abort_command() mecanism using Cancello()
|
||||
// - ECOMTIMEOUT should be return is case of timeout (as of uart_posix implementation)
|
||||
volatile bool * abort_flag_p = (volatile bool *)abort_p;
|
||||
do {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "ReadFile");
|
||||
res = ReadFile (((serial_port_windows *) sp)->hPort, pbtRx + dwTotalBytesReceived,
|
||||
dwBytesToGet,
|
||||
&dwBytesReceived, NULL);
|
||||
|
@ -174,7 +176,10 @@ uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, void * abort_p,
|
|||
DWORD err = GetLastError();
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "ReadFile error: %u", err);
|
||||
return ECOMIO;
|
||||
}
|
||||
} else if (dwBytesReceived == 0) {
|
||||
return ECOMTIMEOUT;
|
||||
}
|
||||
|
||||
if (((DWORD)szRx) > dwTotalBytesReceived) {
|
||||
dwBytesToGet -= dwBytesReceived;
|
||||
}
|
||||
|
@ -183,6 +188,7 @@ uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, void * abort_p,
|
|||
return EOPABORT;
|
||||
}
|
||||
} while (((DWORD)szRx) > dwTotalBytesReceived);
|
||||
LOG_HEX ("RX", pbtRx, szRx);
|
||||
|
||||
return (dwTotalBytesReceived == (DWORD) szRx) ? 0 : ECOMIO;
|
||||
}
|
||||
|
@ -204,6 +210,7 @@ uart_send (serial_port sp, const byte_t * pbtTx, const size_t szTx, struct timev
|
|||
return ECOMIO;
|
||||
}
|
||||
|
||||
LOG_HEX ("TX", pbtTx, szTx);
|
||||
if (!WriteFile (((serial_port_windows *) sp)->hPort, pbtTx, szTx, &dwTxLen, NULL)) {
|
||||
return ECOMIO;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
SET(UTILS-SOURCES nfc-emulate-forum-tag2 nfc-emulate-forum-tag4 nfc-list nfc-relay-picc nfc-mfclassic nfc-mfultralight)
|
||||
|
||||
# XXX: Examples should not use private API!
|
||||
#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libnfc)
|
||||
|
||||
INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS} ${PCSC_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${LIBUSB_LIBRARY_DIRS} ${PCSC_LIBRARY_DIRS})
|
||||
|
||||
ADD_LIBRARY(nfcutils STATIC
|
||||
nfc-utils.c
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue