How can I detect which baudrate a virtual COM port is set to?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I would like my software running on Leonardo to behave differently depending on the baudrate of the USB Serial set by the PC. For example, I want to make a smart USB to UART converter which performs some processing of the data it transmits. It would be much more elegant to set the UART baudrate to whatever value the PC is requesting on USB side, rather than hardcoding a value.
AFAIK 32u4 chip is used as a USB to UART converter on Mega, where it supports different baudrates, so this should be doable.
I also have a Teensy 3.2 board, so if anyone knows how to detect the baudrate on this board I'm also interested.
serial usb arduino-leonardo teensy
add a comment |Â
up vote
2
down vote
favorite
I would like my software running on Leonardo to behave differently depending on the baudrate of the USB Serial set by the PC. For example, I want to make a smart USB to UART converter which performs some processing of the data it transmits. It would be much more elegant to set the UART baudrate to whatever value the PC is requesting on USB side, rather than hardcoding a value.
AFAIK 32u4 chip is used as a USB to UART converter on Mega, where it supports different baudrates, so this should be doable.
I also have a Teensy 3.2 board, so if anyone knows how to detect the baudrate on this board I'm also interested.
serial usb arduino-leonardo teensy
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I would like my software running on Leonardo to behave differently depending on the baudrate of the USB Serial set by the PC. For example, I want to make a smart USB to UART converter which performs some processing of the data it transmits. It would be much more elegant to set the UART baudrate to whatever value the PC is requesting on USB side, rather than hardcoding a value.
AFAIK 32u4 chip is used as a USB to UART converter on Mega, where it supports different baudrates, so this should be doable.
I also have a Teensy 3.2 board, so if anyone knows how to detect the baudrate on this board I'm also interested.
serial usb arduino-leonardo teensy
I would like my software running on Leonardo to behave differently depending on the baudrate of the USB Serial set by the PC. For example, I want to make a smart USB to UART converter which performs some processing of the data it transmits. It would be much more elegant to set the UART baudrate to whatever value the PC is requesting on USB side, rather than hardcoding a value.
AFAIK 32u4 chip is used as a USB to UART converter on Mega, where it supports different baudrates, so this should be doable.
I also have a Teensy 3.2 board, so if anyone knows how to detect the baudrate on this board I'm also interested.
serial usb arduino-leonardo teensy
asked Aug 29 at 20:21
Dmitry Grigoryev
855318
855318
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
6
down vote
accepted
From looking at the source it appears that on 32u4 based boards Serial
includes extra methods to access the settings from the USB host:
see: https://github.com/arduino/ArduinoCore-avr/blob/b7c607663fecc232e598f2c0acf419ceb0b7078c/cores/arduino/USBAPI.h#L129
From USBAPI.h:
// These return the settings specified by the USB host for the
// serial port. These aren't really used, but are offered here
// in case a sketch wants to act on these settings.
uint32_t baud();
uint8_t stopbits();
uint8_t paritytype();
uint8_t numbits();
bool dtr();
bool rts();
1
I tried it out. On Leonardo,Serial.baud()
works right after the serial has started, insidesetup
. On Teensy,Serial.baud()
seems to return 0 insidesetup
, so I wait insideloop
until a non-zero value is returned.
â Dmitry Grigoryev
Aug 30 at 7:19
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
accepted
From looking at the source it appears that on 32u4 based boards Serial
includes extra methods to access the settings from the USB host:
see: https://github.com/arduino/ArduinoCore-avr/blob/b7c607663fecc232e598f2c0acf419ceb0b7078c/cores/arduino/USBAPI.h#L129
From USBAPI.h:
// These return the settings specified by the USB host for the
// serial port. These aren't really used, but are offered here
// in case a sketch wants to act on these settings.
uint32_t baud();
uint8_t stopbits();
uint8_t paritytype();
uint8_t numbits();
bool dtr();
bool rts();
1
I tried it out. On Leonardo,Serial.baud()
works right after the serial has started, insidesetup
. On Teensy,Serial.baud()
seems to return 0 insidesetup
, so I wait insideloop
until a non-zero value is returned.
â Dmitry Grigoryev
Aug 30 at 7:19
add a comment |Â
up vote
6
down vote
accepted
From looking at the source it appears that on 32u4 based boards Serial
includes extra methods to access the settings from the USB host:
see: https://github.com/arduino/ArduinoCore-avr/blob/b7c607663fecc232e598f2c0acf419ceb0b7078c/cores/arduino/USBAPI.h#L129
From USBAPI.h:
// These return the settings specified by the USB host for the
// serial port. These aren't really used, but are offered here
// in case a sketch wants to act on these settings.
uint32_t baud();
uint8_t stopbits();
uint8_t paritytype();
uint8_t numbits();
bool dtr();
bool rts();
1
I tried it out. On Leonardo,Serial.baud()
works right after the serial has started, insidesetup
. On Teensy,Serial.baud()
seems to return 0 insidesetup
, so I wait insideloop
until a non-zero value is returned.
â Dmitry Grigoryev
Aug 30 at 7:19
add a comment |Â
up vote
6
down vote
accepted
up vote
6
down vote
accepted
From looking at the source it appears that on 32u4 based boards Serial
includes extra methods to access the settings from the USB host:
see: https://github.com/arduino/ArduinoCore-avr/blob/b7c607663fecc232e598f2c0acf419ceb0b7078c/cores/arduino/USBAPI.h#L129
From USBAPI.h:
// These return the settings specified by the USB host for the
// serial port. These aren't really used, but are offered here
// in case a sketch wants to act on these settings.
uint32_t baud();
uint8_t stopbits();
uint8_t paritytype();
uint8_t numbits();
bool dtr();
bool rts();
From looking at the source it appears that on 32u4 based boards Serial
includes extra methods to access the settings from the USB host:
see: https://github.com/arduino/ArduinoCore-avr/blob/b7c607663fecc232e598f2c0acf419ceb0b7078c/cores/arduino/USBAPI.h#L129
From USBAPI.h:
// These return the settings specified by the USB host for the
// serial port. These aren't really used, but are offered here
// in case a sketch wants to act on these settings.
uint32_t baud();
uint8_t stopbits();
uint8_t paritytype();
uint8_t numbits();
bool dtr();
bool rts();
answered Aug 29 at 21:14
Craig
1,645410
1,645410
1
I tried it out. On Leonardo,Serial.baud()
works right after the serial has started, insidesetup
. On Teensy,Serial.baud()
seems to return 0 insidesetup
, so I wait insideloop
until a non-zero value is returned.
â Dmitry Grigoryev
Aug 30 at 7:19
add a comment |Â
1
I tried it out. On Leonardo,Serial.baud()
works right after the serial has started, insidesetup
. On Teensy,Serial.baud()
seems to return 0 insidesetup
, so I wait insideloop
until a non-zero value is returned.
â Dmitry Grigoryev
Aug 30 at 7:19
1
1
I tried it out. On Leonardo,
Serial.baud()
works right after the serial has started, inside setup
. On Teensy, Serial.baud()
seems to return 0 inside setup
, so I wait inside loop
until a non-zero value is returned.â Dmitry Grigoryev
Aug 30 at 7:19
I tried it out. On Leonardo,
Serial.baud()
works right after the serial has started, inside setup
. On Teensy, Serial.baud()
seems to return 0 inside setup
, so I wait inside loop
until a non-zero value is returned.â Dmitry Grigoryev
Aug 30 at 7:19
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2farduino.stackexchange.com%2fquestions%2f55718%2fhow-can-i-detect-which-baudrate-a-virtual-com-port-is-set-to%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password