-
Notifications
You must be signed in to change notification settings - Fork 7.6k
No real-time serial.read() possible #6921
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
Comments
Hello @OekoSolveMG, thanks for your precise issue report. Is there any reason for you to run your code on Arduino v.2.0.2? I will suggest to retest your code on v2.0.3, there were some changes made on Serial. |
Thanks a lot for the fast response as written above, I wanted to try it but it seems that it hasn't been included in platformio yet. I'll definetly try it once it is available tough. |
Nvm seems I have the newest version as well, was confused because at least in the release note the corresponding espressif32 version is written to be
|
So it looks like the issue is persisting despite the recent changes to the Serial handling. |
Could you please try this solution: // Necessary include for testing the fix
#include "driver/uart.h"
void setup() {
// for example, start Serial - UART0
Serial.begin(115200);
// right after starting UART0, add this code:
uart_intr_config_t uart_intr = {
.intr_enable_mask = (0x1<<0) | (0x8<<0), // UART_INTR_RXFIFO_FULL | UART_INTR_RXFIFO_TOUT,
.rx_timeout_thresh = 1,
.txfifo_empty_intr_thresh = 10,
.rxfifo_full_thresh = 112,
};
uart_intr_config((uart_port_t) 0, &uart_intr); // Zero is the UART number for Arduino Serial
} I think that adding this fix may make UART RX faster and "real time". Thanks! |
The pin seems to be toggling differently now. The read doesn't seem to start until the message has been sent completly. Will let it run over night and see if the issue doesn't occur anymore but the LA result looks different (Especially relevenat is the third line that toggles to HIGH before |
Let it run for a while now and the error happened again but this time it was different. This time it didn't insert the next request into the first one, but it seems like it still couldn't successfully read all the data from the message. It still only seems to read part of the first response and then stops. Logoutput:
Marked until which part of the message was read: |
We have done a few updates to UART in the new Arduino Core 2.0.5 version.
|
Excellent, thanks! I already deployed the |
Please help testing this under 2.0.5 for feedback collection. Next step is to create examples and update Documentation. |
I have tested the changes from PR #6930 that adds The testing was done receiving 125 bytes to UART RX from an external device at 9600 baud. Default Arduino 2.0.5 Behavior (after just using
|
Board
M5 Stack Core 1 / 2
Device Description
M5 Stack Core 1 / 2 with the LAN Module with W5500
Hardware Configuration
Pinmap M5 Core 2
Pinmap Lan module
Version
v2.0.3
IDE Name
PlatformIO
Operating System
Windows 10
Flash frequency
40 MHz
PSRAM enabled
no
Upload speed
115200
Description
Low baudrate (9600) causes the
serial.read()
command to fail and not read bytes on the Modbus. Might there be some interfering code that runs in timed cycles with a very high priority that could creates issues for theserial.read()
.The failed read seen above happens every 6th read.
Complete message:
The third line is a pin that gets toggled to high before
serial.read()
and to low afterseral.read()
.Sketch
Debug Message
Other Steps to Reproduce
See issue on the eModbus library about the same problem. Conclusion was that it might be a problem with the Base library. (eModbus/eModbus#198)
The same issue happens on both Core 1 and Core 2 as well as with a custom adapter for modbus or the WAN 5500 module.
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: