mirror of
https://github.com/nfc-tools/libnfc.git
synced 2026-03-12 10:33:47 +00:00
Timeout is now integer.
This commit is contained in:
@@ -49,8 +49,8 @@ void uart_flush_input (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, uint8_t * pbtRx, const size_t szRx, void * abort_p, struct timeval *timeout);
|
||||
int uart_send (serial_port sp, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout);
|
||||
int uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p, int timeout);
|
||||
int uart_send (serial_port sp, const uint8_t * pbtTx, const size_t szTx, int timeout);
|
||||
|
||||
char **uart_list_ports (void);
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ uart_close (const serial_port sp)
|
||||
* @return 0 on success, otherwise driver error code
|
||||
*/
|
||||
int
|
||||
uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p, struct timeval *timeout)
|
||||
uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p, int timeout)
|
||||
{
|
||||
int iAbortFd = abort_p ? *((int*)abort_p) : 0;
|
||||
int received_bytes_count = 0;
|
||||
@@ -272,12 +272,13 @@ select:
|
||||
* Make a copy so that it will be updated on these systems,
|
||||
*/
|
||||
struct timeval fixed_timeout;
|
||||
if (timeout) {
|
||||
fixed_timeout = *timeout;
|
||||
timeout = &fixed_timeout;
|
||||
if (timeout > 0) {
|
||||
fixed_timeout.tv_sec = (timeout / 1000);
|
||||
fixed_timeout.tv_usec = ((timeout % 1000) * 1000);
|
||||
timeout = ((fixed_timeout.tv_sec * 1000) + (fixed_timeout.tv_usec / 1000));
|
||||
}
|
||||
|
||||
res = select (MAX(UART_DATA(sp)->fd, iAbortFd) + 1, &rfds, NULL, NULL, timeout);
|
||||
res = select (MAX(UART_DATA(sp)->fd, iAbortFd) + 1, &rfds, NULL, NULL, &fixed_timeout);
|
||||
|
||||
if ((res < 0) && (EINTR == errno)) {
|
||||
// The system call was interupted by a signal and a signal handler was
|
||||
@@ -327,7 +328,7 @@ select:
|
||||
* @return 0 on success, otherwise a driver error is returned
|
||||
*/
|
||||
int
|
||||
uart_send (serial_port sp, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout)
|
||||
uart_send (serial_port sp, const uint8_t * pbtTx, const size_t szTx, int timeout)
|
||||
{
|
||||
(void) timeout;
|
||||
LOG_HEX ("TX", pbtTx, szTx);
|
||||
|
||||
@@ -139,7 +139,7 @@ uart_get_speed (const serial_port sp)
|
||||
}
|
||||
|
||||
int
|
||||
uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p, struct timeval *timeout)
|
||||
uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p, int timeout)
|
||||
{
|
||||
DWORD dwBytesToGet = (DWORD)szRx;
|
||||
DWORD dwBytesReceived = 0;
|
||||
@@ -147,7 +147,7 @@ uart_receive (serial_port sp, uint8_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;
|
||||
DWORD timeout_ms = timeout;
|
||||
COMMTIMEOUTS timeouts;
|
||||
timeouts.ReadIntervalTimeout = 0;
|
||||
timeouts.ReadTotalTimeoutMultiplier = 0;
|
||||
@@ -194,16 +194,16 @@ uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p
|
||||
}
|
||||
|
||||
int
|
||||
uart_send (serial_port sp, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout)
|
||||
uart_send (serial_port sp, const uint8_t * pbtTx, const size_t szTx, int timeout)
|
||||
{
|
||||
DWORD dwTxLen = 0;
|
||||
|
||||
COMMTIMEOUTS timeouts;
|
||||
timeouts.ReadIntervalTimeout = 0;
|
||||
timeouts.ReadTotalTimeoutMultiplier = 0;
|
||||
timeouts.ReadTotalTimeoutConstant = timeout ? ((timeout->tv_sec * 1000) + (timeout->tv_usec / 1000)) : 0;
|
||||
timeouts.ReadTotalTimeoutConstant = timeout;
|
||||
timeouts.WriteTotalTimeoutMultiplier = 0;
|
||||
timeouts.WriteTotalTimeoutConstant = timeout ? ((timeout->tv_sec * 1000) + (timeout->tv_usec / 1000)) : 0;
|
||||
timeouts.WriteTotalTimeoutConstant = timeout;
|
||||
|
||||
if (!SetCommTimeouts (((struct serial_port_windows *) sp)->hPort, &timeouts)) {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Unable to apply new timeout settings.");
|
||||
|
||||
Reference in New Issue
Block a user