Unverified Commit f5f7267f authored by rlcamp's avatar rlcamp Committed by GitHub

Add Serial.dtr() and Serial.rts() methods (#1779)

* add Serial.dtr() and Serial.rts() methods

* added documentation for Serial.dtr() and Serial.rts()
parent a4ad8ae0
...@@ -197,6 +197,14 @@ static void CheckSerialReset() { ...@@ -197,6 +197,14 @@ static void CheckSerialReset() {
} }
} }
bool SerialUSB::dtr() {
return _dtr;
}
bool SerialUSB::rts() {
return _rts;
}
extern "C" void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) { extern "C" void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) {
(void) itf; (void) itf;
_dtr = dtr ? true : false; _dtr = dtr ? true : false;
......
...@@ -43,6 +43,8 @@ public: ...@@ -43,6 +43,8 @@ public:
virtual size_t write(const uint8_t *p, size_t len) override; virtual size_t write(const uint8_t *p, size_t len) override;
using Print::write; using Print::write;
operator bool() override; operator bool() override;
bool dtr();
bool rts();
void ignoreFlowControl(bool ignore = true); void ignoreFlowControl(bool ignore = true);
......
...@@ -55,3 +55,13 @@ void Serial.ignoreFlowControl(bool ignore) ...@@ -55,3 +55,13 @@ void Serial.ignoreFlowControl(bool ignore)
In some cases, the target application will not assert the DTR virtual line, thus preventing writing operations to succeed. In some cases, the target application will not assert the DTR virtual line, thus preventing writing operations to succeed.
For this reason, the SerialUSB::ignoreFlowControl() method disables the connection's state verification, enabling the program to write on the port, even though the data might be lost. For this reason, the SerialUSB::ignoreFlowControl() method disables the connection's state verification, enabling the program to write on the port, even though the data might be lost.
bool Serial.dtr()
~~~~~~~~~~~~~~~~~
Returns the current state of the DTR virtual line. A USB CDC host (such as the Arduino serial monitor) typically raises the DTR pin when opening the device, and may lower it when closing the device.
bool Serial.rts()
~~~~~~~~~~~~~~~~~
Returns the current state of the RTS virtual line.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment