Changed Serial.read() to non blocking and retuns -1 if no char available (Like the 1.0.x API)
This commit is contained in:
parent
4fdce817a4
commit
cd3a72a54d
|
@ -171,8 +171,19 @@ uint32 USBSerial::read(void *buf, uint32 len) {
|
|||
/* Blocks forever until 1 byte is received */
|
||||
int USBSerial::read(void) {
|
||||
uint8 b;
|
||||
this->read(&b, 1);
|
||||
/*
|
||||
this->read(&b, 1);
|
||||
return b;
|
||||
*/
|
||||
|
||||
if (!usb_cdcacm_rx(&b, 1))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
uint8 USBSerial::pending(void) {
|
||||
|
|
Loading…
Reference in New Issue