timeout reconfiguration: flag was never cleared and some more changes:
* clear newtimeout_pending flag * fix initial newtimeout_pending flag value on win32 * remove all _atomic as anyway a load+clear wouldn't be atomic and we're not in a critical situation: just one writer seldomly called on reconnect * move new timeout poll to uart_recv for faster deployment * remove redundant uart_reconfigure_timeouts(UART_FPC_CLIENT_RX_TIMEOUT_MS);
This commit is contained in:
@@ -49,18 +49,18 @@ typedef struct {
|
||||
} serial_port_windows;
|
||||
|
||||
uint32_t newtimeout_value = 0;
|
||||
bool newtimeout_pending = true;
|
||||
bool newtimeout_pending = false;
|
||||
|
||||
int uart_reconfigure_timeouts(uint32_t value) {
|
||||
newtimeout_value = value;
|
||||
__atomic_test_and_set(&newtimeout_pending, __ATOMIC_SEQ_CST);
|
||||
newtimeout_pending = true;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int uart_reconfigure_timeouts_polling(serial_port sp) {
|
||||
bool shall_update = __atomic_load_n(&newtimeout_pending, __ATOMIC_SEQ_CST);
|
||||
if ( shall_update == false )
|
||||
if ( newtimeout_pending == false )
|
||||
return PM3_SUCCESS;
|
||||
newtimeout_pending = false;
|
||||
|
||||
serial_port_windows *spw;
|
||||
spw = (serial_port_windows *)sp;
|
||||
@@ -174,6 +174,7 @@ uint32_t uart_get_speed(const serial_port sp) {
|
||||
}
|
||||
|
||||
int uart_receive(const serial_port sp, uint8_t *pbtRx, uint32_t pszMaxRxLen, uint32_t *pszRxLen) {
|
||||
uart_reconfigure_timeouts_polling(sp);
|
||||
int res = ReadFile(((serial_port_windows *)sp)->hPort, pbtRx, pszMaxRxLen, (LPDWORD)pszRxLen, NULL);
|
||||
if (res)
|
||||
return PM3_SUCCESS;
|
||||
@@ -190,7 +191,6 @@ int uart_receive(const serial_port sp, uint8_t *pbtRx, uint32_t pszMaxRxLen, uin
|
||||
}
|
||||
|
||||
int uart_send(const serial_port sp, const uint8_t *p_tx, const uint32_t len) {
|
||||
uart_reconfigure_timeouts_polling(sp);
|
||||
DWORD txlen = 0;
|
||||
int res = WriteFile(((serial_port_windows *)sp)->hPort, p_tx, len, &txlen, NULL);
|
||||
if (res)
|
||||
|
||||
Reference in New Issue
Block a user