]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - common/usb_cdc.c
Potential fix for 0-length usb packets seen on OSX
[proxmark3-svn] / common / usb_cdc.c
index ccbb3c50e91389a4d733e25f75c7f94e50e77ef5..3c6e928238d11b285e66375ce1ffff2bb28946e2 100644 (file)
@@ -293,6 +293,22 @@ bool usb_poll()
   return (pUdp->UDP_CSR[AT91C_EP_OUT] & btReceiveBank);\r
 }\r
 \r
+/**\r
+       In github PR #129, some users appears to get a false positive from\r
+       usb_poll, which returns true, but the usb_read operation\r
+       still returns 0.\r
+       This check is basically the same as above, but also checks\r
+       that the length available to read is non-zero, thus hopefully fixes the\r
+       bug.\r
+**/\r
+bool usb_poll_validate_length()\r
+{\r
+\r
+       if (!usb_check()) return false;\r
+       if (!(pUdp->UDP_CSR[AT91C_EP_OUT] & btReceiveBank)) return false;\r
+       return (pUdp->UDP_CSR[AT91C_EP_OUT] >> 16) >  0;\r
+}\r
+\r
 //*----------------------------------------------------------------------------\r
 //* \fn    usb_read\r
 //* \brief Read available data from Endpoint OUT\r
Impressum, Datenschutz