-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Change baud on the fly #441
Comments
Hi @Papengut , try |
Hi @jestebanes,
Same result at Serial2.end()! Program stopped execution. |
I'll have a look at the end command, but you do not need to call it. Just Serial2.begin(new baud) should do |
Hi @jestebanes,
Result of my test: The program didn't stop execution, but Serial2 didn't work in line 7. |
I have a very similar issue regarding changing the baud rate E |
What about this? void setup() {
Serial.begin(115200);
Serial.println("loool1");
Serial.flush();
delay(1000);
Serial.begin(9600);
Serial.println("loool2");
Serial.flush();
delay(1000);
Serial.begin(115200);
Serial.println("loool3");
}
void loop() {
} |
@copercini I first setup the serial @9600baud, perform some read/writes then So I am guessing there is a FIFO involved here and it is only emptying the FIFO Not sure what is magical about 5 x 24 - default buffer size perhaps ? This only seems to occur when the baud rate has been configured at 9600, then changed Something is very wrong, but I think it must be down in the driver detail somewhere E. |
@eroom1966 please post some code, how are you testing it? via computer serial? |
Hello @eroom1966, When you write to serial, the low-level functions are asynchronous, look into esp32-hal-uart.c functions uartWrite and uartWriteBuf, they only put your bytes in a FIFO buffer and then exit. But now I see in line 194 of esp32-hal-uart.c -> uartFlush(uart); inside the begin operation, then apparently there isn't a necessity of making a flush previous to the new Begin operation. JEE |
@jestebanes OK, I am no expert on this Architecture, but this looks very suspicious at line 300 UART_MUTEX_LOCK(); This looks like deadlock code I presume another thread is emptying (and decrementing) this counter, using the same mutex, unfortunately, you now have a deadlock, because this mutex is not released until the count is zero, Hmmm, seems like a better approach is a condvar (assuming this library has such a feature) E. |
Hi All I have the perfect testcase to show this issue - if anybody can make this work, that would be wonderful |
Should be OK now! Please test and confirm :) |
@Papengut Are you able to test this issue? |
Yes, but earliest next week. |
Hello, I try to test it, but I am missing some information and so I write here all details:
Did I something wrong? |
I reopen the issue because it didn't work for me. Please look at last entry here. |
Why don't you try Serial.changeBaud(baud); |
I used "hwSerial->changeBaud(baud)" because my serial device (=VC0706) used Serial2. Serial1 was my debugging output. At Serial1 change Baud worked! If I start the Sketch, Serial1 used baud=115200. Then I call "Serial.changeBaud(9600)" and I got all messages with 9600. Fine. My trick for Serial2:
This worked for Serial2. This problem is the call of "changeBaud". I will analyze it. |
My last problem was "hwSerial->changeBaud(baud)". Now I used:
This worked fine for me. Please add "uartChangeBaudRat" and "changeBaud" to the libraries. |
Hi, it works for me in serial2, thanks @Papengut I propose another couple of functions to change the baud-rate and Parity //esp32-hal-uart.c
} // HardwareSerial.cpp |
this seems to work for me:
|
hello everyone, unsigned long baudrate1 = 9600; void setup() void loop() Serial.updateBaudRate(baudrate1); } //----------------- |
Hello,
I like to change baudrate for an ESP32 on the fly to communicate with a VC0706.
My idea is:
-> It didn't not work. The ESP32 stopped at line 4.)
My idea of an very easy test was:
Is this an issue?
The text was updated successfully, but these errors were encountered: