Changed Serial.read() to non blocking and retuns -1 if no char available (Like the 1.0.x API)

This commit is contained in:
Roger Clark 2014-12-04 21:31:05 +11:00
parent 4fdce817a4
commit cd3a72a54d
1 changed files with 12 additions and 1 deletions

View File

@ -171,8 +171,19 @@ uint32 USBSerial::read(void *buf, uint32 len) {
/* Blocks forever until 1 byte is received */ /* Blocks forever until 1 byte is received */
int USBSerial::read(void) { int USBSerial::read(void) {
uint8 b; uint8 b;
/*
this->read(&b, 1); this->read(&b, 1);
return b; return b;
*/
if (!usb_cdcacm_rx(&b, 1))
{
return -1;
}
else
{
return b;
}
} }
uint8 USBSerial::pending(void) { uint8 USBSerial::pending(void) {