Skip to content

Unable to set the number of data bits on serial port in Uart::begin due to data type width #83

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
TomKeddie opened this issue Jan 3, 2016 · 1 comment

Comments

@TomKeddie
Copy link
Contributor

These constants for the number of data bits are all 16 bit values.

#define HARDSER_DATA_5      (0x100ul)
#define HARDSER_DATA_6      (0x200ul)
#define HARDSER_DATA_7      (0x300ul)
#define HARDSER_DATA_8      (0x400ul)
#define HARDSER_DATA_MASK   (0xF00ul)`

But Uart::begin takes an 8 bit value
void begin(unsigned long baudrate, uint8_t config);

This makes it impossible to change the number of bits.

@keestux
Copy link

keestux commented Feb 27, 2017

This problem is not fixed properly. Argument config was changed to uint16_t as shown below

void Uart::begin(unsigned long baudrate, uint16_t config)

however the other Uart::begin calls it with a cast to uint8_t

void Uart::begin(unsigned long baudrate)
{
  begin(baudrate, (uint8_t)SERIAL_8N1);
}

So far, nobody noticed, probably because nobody uses other than 8 data bits. In that case you won't notice the bug.
Wouldn't it be better to drop this latter function and to add a default value for config in the other begin()?

boseji pushed a commit to go-ut/combined-ArduinoCore-samd that referenced this issue May 30, 2020
AR_INTERNAL was removed in arduino#74. Because of this, non-SAMD51 boards fail because AR_INTERNAL isn't defined.
This also define AR_INTERNAL_2V23, which is also used for non-SAMD51
boards.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants