File tree 2 files changed +46
-0
lines changed
2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -299,6 +299,30 @@ Serial_::operator bool()
299
299
return result;
300
300
}
301
301
302
+ unsigned long Serial_::baud () {
303
+ return _usbLineInfo.dwDTERate ;
304
+ }
305
+
306
+ uint8_t Serial_::stopbits () {
307
+ return _usbLineInfo.bCharFormat ;
308
+ }
309
+
310
+ uint8_t Serial_::paritytype () {
311
+ return _usbLineInfo.bParityType ;
312
+ }
313
+
314
+ uint8_t Serial_::numbits () {
315
+ return _usbLineInfo.bDataBits ;
316
+ }
317
+
318
+ bool Serial_::dtr () {
319
+ return _usbLineInfo.lineState & 0x1 ;
320
+ }
321
+
322
+ bool Serial_::rts () {
323
+ return _usbLineInfo.lineState & 0x2 ;
324
+ }
325
+
302
326
Serial_ SerialUSB;
303
327
304
328
#endif
Original file line number Diff line number Diff line change @@ -61,6 +61,28 @@ class Serial_ : public Stream
61
61
virtual size_t write (const uint8_t *buffer, size_t size);
62
62
using Print::write; // pull in write(str) from Print
63
63
operator bool ();
64
+
65
+ // These return the settings specified by the USB host for the
66
+ // serial port. These aren't really used, but are offered here
67
+ // in case a sketch wants to act on these settings.
68
+ uint32_t baud ();
69
+ uint8_t stopbits ();
70
+ uint8_t paritytype ();
71
+ uint8_t numbits ();
72
+ bool dtr ();
73
+ bool rts ();
74
+ enum {
75
+ ONE_STOP_BIT = 0 ,
76
+ ONE_AND_HALF_STOP_BIT = 1 ,
77
+ TWO_STOP_BITS = 2 ,
78
+ };
79
+ enum {
80
+ NO_PARITY = 0 ,
81
+ ODD_PARITY = 1 ,
82
+ EVEN_PARITY = 2 ,
83
+ MARK_PARITY = 3 ,
84
+ SPACE_PARITY = 4 ,
85
+ };
64
86
};
65
87
extern Serial_ SerialUSB;
66
88
You can’t perform that action at this time.
0 commit comments