mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-19 04:49:38 -07:00
Patch by jonor, fixes so uart_receive does not block when data is continuosly received. See http://www.proxmark.org/forum/viewtopic.php?id=1735
This commit is contained in:
parent
7cf3ef203c
commit
babfcaa0f3
1 changed files with 9 additions and 6 deletions
|
@ -266,7 +266,7 @@ bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen) {
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read time-out
|
// Read time-out
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
if (*pszRxLen == 0) {
|
if (*pszRxLen == 0) {
|
||||||
|
@ -277,21 +277,24 @@ bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the count of the incoming bytes
|
// Retrieve the count of the incoming bytes
|
||||||
res = ioctl(((serial_port_unix*)sp)->fd, FIONREAD, &byteCount);
|
res = ioctl(((serial_port_unix*)sp)->fd, FIONREAD, &byteCount);
|
||||||
if (res < 0) return false;
|
if (res < 0) return false;
|
||||||
|
|
||||||
// There is something available, read the data
|
// There is something available, read the data
|
||||||
res = read(((serial_port_unix*)sp)->fd,pbtRx+(*pszRxLen),byteCount);
|
res = read(((serial_port_unix*)sp)->fd,pbtRx+(*pszRxLen),byteCount);
|
||||||
|
|
||||||
// Stop if the OS has some troubles reading the data
|
// Stop if the OS has some troubles reading the data
|
||||||
if (res <= 0) return false;
|
if (res <= 0) return false;
|
||||||
|
|
||||||
*pszRxLen += res;
|
*pszRxLen += res;
|
||||||
|
|
||||||
|
if(res==byteCount)
|
||||||
|
return true;
|
||||||
|
|
||||||
} while (byteCount);
|
} while (byteCount);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue