Skip to content

Add rts dtr and baudrate public functions in CDC Serial_ class #1179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions hardware/arduino/cores/arduino/CDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions hardware/arduino/cores/arduino/USBAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down