diff --git a/hardware/arduino/cores/arduino/CDC.cpp b/hardware/arduino/cores/arduino/CDC.cpp index e1e859d18c4..c490ef11be6 100644 --- a/hardware/arduino/cores/arduino/CDC.cpp +++ b/hardware/arduino/cores/arduino/CDC.cpp @@ -237,6 +237,23 @@ Serial_::operator bool() { return result; } + +unsigned long Serial_::baudrate(void) +{ + return _usbLineInfo.dwDTERate; +} + +bool Serial_::dtr(void) +{ + return (_usbLineInfo.lineState & 0x01) == 0x01; +} + +bool Serial_::rts(void) +{ + return (_usbLineInfo.lineState & 0x02) == 0x02; +} + + Serial_ Serial; #endif diff --git a/hardware/arduino/cores/arduino/USBAPI.h b/hardware/arduino/cores/arduino/USBAPI.h index 7a14285db05..b0e51282e17 100644 --- a/hardware/arduino/cores/arduino/USBAPI.h +++ b/hardware/arduino/cores/arduino/USBAPI.h @@ -40,6 +40,9 @@ class Serial_ : public Stream virtual int read(void); virtual void flush(void); virtual size_t write(uint8_t); + virtual unsigned long baudrate(void); + virtual bool dtr(void); + virtual bool rts(void); using Print::write; // pull in write(str) and write(buf, size) from Print operator bool(); };