mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-02 13:24:12 +01:00
on a CDC or HID write() error, call setWriteError(). better handling of USB_Send errors in CDC.
This commit is contained in:
parent
6049e4455a
commit
7d26163b16
@ -166,9 +166,15 @@ size_t Serial_::write(uint8_t c)
|
|||||||
// open connection isn't broken cleanly (cable is yanked out, host dies
|
// open connection isn't broken cleanly (cable is yanked out, host dies
|
||||||
// or locks up, or host virtual serial port hangs)
|
// or locks up, or host virtual serial port hangs)
|
||||||
if (_usbLineInfo.lineState > 0) {
|
if (_usbLineInfo.lineState > 0) {
|
||||||
USB_Send(CDC_TX,&c,1);
|
int r = USB_Send(CDC_TX,&c,1);
|
||||||
return 1;
|
if (r > 0) {
|
||||||
|
return r;
|
||||||
|
} else {
|
||||||
|
setWriteError();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
setWriteError();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,11 +398,15 @@ size_t Keyboard_::write(uint8_t c)
|
|||||||
_keyMap->charToKey(c,&keys);
|
_keyMap->charToKey(c,&keys);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (c >= 128)
|
if (c >= 128) {
|
||||||
|
setWriteError();
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
c = pgm_read_byte(_asciimap + c);
|
c = pgm_read_byte(_asciimap + c);
|
||||||
if (!c)
|
if (!c) {
|
||||||
|
setWriteError();
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
if (c & 0x80)
|
if (c & 0x80)
|
||||||
{
|
{
|
||||||
keys.modifiers |= KEY_MODIFIER_LEFT_SHIFT;
|
keys.modifiers |= KEY_MODIFIER_LEFT_SHIFT;
|
||||||
|
Loading…
Reference in New Issue
Block a user