mirror of
https://github.com/nfc-tools/libnfc.git
synced 2026-03-12 02:23:47 +00:00
Attempt to provide an abort mecanism for windows users...
This commit is contained in:
@@ -46,7 +46,7 @@ void uart_close (const serial_port sp);
|
||||
void uart_set_speed (serial_port sp, const uint32_t uiPortSpeed);
|
||||
uint32_t uart_get_speed (const serial_port sp);
|
||||
|
||||
int uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, int iAbortFd);
|
||||
int uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, void * abort_p);
|
||||
int uart_send (serial_port sp, const byte_t * pbtTx, const size_t szTx);
|
||||
|
||||
char **uart_list_ports (void);
|
||||
|
||||
@@ -224,8 +224,9 @@ static const struct timeval tvTimeout = {
|
||||
* @return 0 on success, otherwise driver error code
|
||||
*/
|
||||
int
|
||||
uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, int iAbortFd)
|
||||
uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, void * abort_p)
|
||||
{
|
||||
int iAbortFd = *((int*)abort_p);
|
||||
struct timeval tv = tvTimeout;
|
||||
struct timeval *ptv = &tv;
|
||||
int received_bytes_count = 0;
|
||||
|
||||
@@ -142,13 +142,16 @@ uart_get_speed (const serial_port sp)
|
||||
}
|
||||
|
||||
int
|
||||
uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, int iAbortFd)
|
||||
uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, void * abort_p)
|
||||
{
|
||||
// TODO: Implement abort mecanism (using iAbortFd)
|
||||
// TODO Test me with abort_p
|
||||
volatile bool * abort_flag_p = (volatile bool *)abort_p;
|
||||
DWORD dwRxLen = szRx;
|
||||
if (!ReadFile (((serial_port_windows *) sp)->hPort, pbtRx, dwRxLen, &dwRxLen, NULL)) {
|
||||
return DEIO;
|
||||
}
|
||||
do {
|
||||
if (!ReadFile (((serial_port_windows *) sp)->hPort, pbtRx, dwRxLen, &dwRxLen, NULL)) {
|
||||
return DEIO;
|
||||
}
|
||||
} while ( (dwRxLen != (DWORD) szRx) && ((abort_flag_p) && !(*abort_flag_p)) );
|
||||
return (dwRxLen == (DWORD) szRx) ? 0 : DEIO;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user