mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-19 21:03:23 -07:00
Potential fix for 0-length usb packets seen on OSX
This commit is contained in:
parent
976627d5ba
commit
83f3f8ac40
3 changed files with 18 additions and 5 deletions
|
@ -293,6 +293,22 @@ bool usb_poll()
|
|||
return (pUdp->UDP_CSR[AT91C_EP_OUT] & btReceiveBank);
|
||||
}
|
||||
|
||||
/**
|
||||
In github PR #129, some users appears to get a false positive from
|
||||
usb_poll, which returns true, but the usb_read operation
|
||||
still returns 0.
|
||||
This check is basically the same as above, but also checks
|
||||
that the length available to read is non-zero, thus hopefully fixes the
|
||||
bug.
|
||||
**/
|
||||
bool usb_poll_validate_length()
|
||||
{
|
||||
|
||||
if (!usb_check()) return false;
|
||||
if (!(pUdp->UDP_CSR[AT91C_EP_OUT] & btReceiveBank)) return false;
|
||||
return (pUdp->UDP_CSR[AT91C_EP_OUT] >> 16) > 0;
|
||||
}
|
||||
|
||||
//*----------------------------------------------------------------------------
|
||||
//* \fn usb_read
|
||||
//* \brief Read available data from Endpoint OUT
|
||||
|
|
|
@ -41,6 +41,7 @@ void usb_disable();
|
|||
void usb_enable();
|
||||
bool usb_check();
|
||||
bool usb_poll();
|
||||
bool usb_poll_validate_length();
|
||||
uint32_t usb_read(byte_t* data, size_t len);
|
||||
uint32_t usb_write(const byte_t* data, const size_t len);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue