Skip to content
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

Add HardwareSerial::updateBaudRate(unsigned long baud) #6494

Merged
merged 3 commits into from Sep 16, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions cores/esp8266/HardwareSerial.cpp
Expand Up @@ -60,6 +60,15 @@ void HardwareSerial::end()
_uart = NULL;
}

void HardwareSerial::updateBaudRate(unsigned long baud)
{
if(!_uart) {
return;
}

uart_set_baudrate(_uart, baud);
}

size_t HardwareSerial::setRxBufferSize(size_t size){
if(_uart) {
_rx_size = uart_resize_rx_buffer(_uart, size);
Expand Down Expand Up @@ -133,8 +142,8 @@ unsigned long HardwareSerial::detectBaudrate(time_t timeoutMillis)
return detectedBaudrate;
}

size_t HardwareSerial::readBytes(char* buffer, size_t size)
{
size_t HardwareSerial::readBytes(char* buffer, size_t size)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a linefeed change here? I think this whole file is DOS \r\n formatted, but your patch only has \UNIX n. For now, could you make sure you match the linefeeds of the rest of the file (yes, I hate DOS linefeeds, too, but we need to be consistent in any particular file).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really do not know. I did not touch these lines. Could you please check it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is indeed a crlf change.
And after checking, this PR restores consistency which is not here in current master.
(The Allman process shall have a try-again session)

{
size_t got = 0;

while (got < size)
Expand All @@ -147,7 +156,7 @@ size_t HardwareSerial::readBytes(char* buffer, size_t size)
got += read(buffer + got, std::min(size - got, avail));
}
return got;
}
}

#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
HardwareSerial Serial(UART0);
Expand Down
2 changes: 2 additions & 0 deletions cores/esp8266/HardwareSerial.h
Expand Up @@ -88,6 +88,8 @@ class HardwareSerial: public Stream

void end();

void updateBaudRate(unsigned long baud);

size_t setRxBufferSize(size_t size);
size_t getRxBufferSize()
{
Expand Down