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:
Philippe Teuwen
2019-05-16 12:35:40 +02:00
parent 9b85f80321
commit b5e4a60a15
3 changed files with 14 additions and 17 deletions

View File

@@ -78,7 +78,7 @@ 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;
}
@@ -243,6 +243,10 @@ int uart_receive(const serial_port sp, uint8_t *pbtRx, uint32_t pszMaxRxLen, uin
fd_set rfds;
struct timeval tv;
if ( newtimeout_pending ) {
timeout.tv_usec = newtimeout_value * 1000;
newtimeout_pending = false;
}
// Reset the output count
*pszRxLen = 0;
do {
@@ -303,10 +307,6 @@ int uart_send(const serial_port sp, const uint8_t *pbtTx, const uint32_t len) {
fd_set rfds;
struct timeval tv;
bool shall_update = __atomic_load_n(&newtimeout_pending, __ATOMIC_SEQ_CST);
if ( shall_update )
timeout.tv_usec = newtimeout_value * 1000;
while (pos < len) {
// Reset file descriptor
FD_ZERO(&rfds);