-
Notifications
You must be signed in to change notification settings - Fork 7.6k
No data in the 3rd UART buffer if you use all 3 the same time. #1189
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
@negativekelvin I do not close the port. I also did comment on that issue. |
I don't think it matters, begin calls flush or your code does and triggers a hardware bug. Needs workaround. |
OK so what is the workaround ? |
Have you updated to the latest arduino ? Think that should fix data coming in. However main issue is the data corruption on Serial2.... Anyone any ideas on how to make Serial 2 reliable ? It stops part of my project working.... so need to fix this :( Thanks |
@PhilColbert how do I check the version of the Core. I did do the Git pull and ran get.exe again. But I am not sure if it is the latest version. |
I deleted all the zip files and then ran get.exe again. this was the output.
|
Try running ESP.getSdkVersion() Mine is v3.1-dev-439-g37765d00-dirty I am running arduino as a component by the way. |
@PhilColbert thanks for the reply. do I run that on the ESP32. what do you mean by "I am running arduino as a component by the way." ? |
Installing ESPIDF and then adding the arduino software afterwards. https://github.com/espressif/arduino-esp32/blob/master/docs/esp-idf_component.md |
Aaa OK so you are doing it the other way around. I am using the Arduino IDE. This is my SDK version. v3.1-dev-239-g1c3dd23f-dirty It seems I am running and OLD SDK. How do I update it as I did follow the steps as stated here. https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/windows.md |
I dont think you can do ? It needs the guys running the arduino core to update? I maybe wrong however ! Running with the component and then using Eclipse to code is better ... well it is for me :) plus you get more control over whats going on :) |
Can I use all the Arduino Libaries on the ESPIDF side ? I have done a lot of work on the Arduino side that I would love to bring over if it will work. |
Sure, but you can still use all the espidf stuff now in the arduino code. Adding it as a component means you can do all this still. |
Here is a little test app. This does not work.
Python Code
This is the output on the ESP32 side
and this is the Python side.
|
If I change the code to use UART 1 then the code works. So there is a issue with UART 2 !! This code will work
Here is the output on the ESP32 side.
and the Python side.
|
Would suggest you try commenting out these lines: In arduino flush() is only supposed to empty the TX buffer so if you want to add another function to empty the RX buffer like flushRX() you will have to do it the way esp-idf does it |
Is it this issue ? Note: Problem is I have a GPS on Serial2 which is always sending in data..... Serial is always sending data out and Serial1 can have data in it most of the time.... |
Ok, changed the way flush works to the espidf way..... so it empties the rx and tx buffer and doesnt do the reset. This is ok for me for testing. Removed the lines Kevin mentioned and added 👍 while(uart->dev->status.rxfifo_cnt != 0 || (uart->dev->mem_rx_status.wr_addr != uart->dev->mem_rx_status.rd_addr)) I used to notice strange characters coming out on boot, seemingly still in the serial buffer or an issue when serial2 is reset perhaps ? Now they are gone. Perhaps we need a if on boot (UART==2) ? then dont reset, but clear the buffer out when flush is initially called, I think it needs a workaround as it makes a mess of things ? :) |
I also commented out those 2 lines and the serial part seems to work now. I could get my Modbus sample program to read as well. But when I move it to the bigger program I dont get reads again. But in the bigger program I use threads on the 2 CPU's so I am not sure if that is a problem. I will take the sample modbus program and change it to use taks/threads as well and see if it still works. @PhilColbert did you add that code to a function and call it before each send or how do you use it ? |
Changes the way flush works to clear all RX out of the buffer, this is ok for me. void uartFlush(uart_t* uart)
} Mine issue I think is that, on software restart, as we have removed the reset now, there was characters left in the buffer, so it gets confused and then characters come out randomly. This clears it down completely and all serials can start with no data, as far as I can see, this works. I have done several software restarts and hard restarts and no issues yet. However be aware that flush now clears RX :) Perhaps we should leave these in and then do something else if UART 2 is called ? Then on boot, call a uartRXflush with UART first time its brought up ? Someone else will know best what to do am sure! |
Mmmmm so all is working for me in the sample app without tasks. But as soon as I split it and run it in threads then UART2 wont read the data again. Aaaa this is so frustrating. Why is it such an issue just to get serial ports working. |
To be honest I find it quite bizarre this issue hasnt come up before or sorted ? Useful to be able to use all 3 serials and software restart. Mine still running 100%, seems fixed for what I need, would like to see something added to the codebase to make this work ok for other people. |
OK so I found what is causing the last UART not to have data in the buffer. But I don't know how to fix it.
then I do not get any data in the read buffer from the last UART. @PhilColbert do you have a OLED screen to test this with also ? |
AAAAAAaaaaaaaaaaaaaaa I am so sorry I found the issue. The screen OLED reset pin was set to pin 4 and that is the same pin as one of the UART pins that the last UART was set-up to use. |
Ha :) that would do it ! Sounds like you have solved the issue, my setup is 100% now since changing the flush, all 3 UARTS work perfectly and software reset works. Glad thats sorted, was getting worried at one point! |
All seems to be working now 100%. Thanks all for the help. |
Well its not really a closed issue? Its still broken and needs a proper fix coding and releasing doesnt it ? |
@PhilColbert should we not open a new issue just for the UART flush issue? |
think that would be a good idea , it does need fixing for other people
doesnt it ?
…On 12 Mar 2018 9:16 a.m., "JacoFourie" ***@***.***> wrote:
@PhilColbert <https://github.com/philcolbert> should we not open a new
issue just for the UART flush issue?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1189 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AREdwLEk8j_bbFMjnN5wOMBzT9MLIIFFks5tdi7RgaJpZM4Sfh4E>
.
|
Hi,
Any idea where Thanks |
Yes the Jan 17 update |
OK I think this is the one I am using, however it is the patched version stickbreaker to cope with the I2C (Wire) issue. |
Great!! |
From my point of view, it can and it cant, it does change the way flush works, to keep compatibility with arduino which flush means clear tx and not RX out then this change cant be added. It needs more work to change the way serial starts to use this method instead of calling flush and then this is then left as it was ? Someone with more knowledge of the full startup and flush of serial needs to sort :) I have had my serial 2 running and rebooting for 75 hours now with no issues :) |
Maybe a new function should be added to flush RX and leave to original flush ? |
@JacoFourie @me-no-dev Thanks in advance |
Ok, I have modified the esp32-hal-uart.c in the cores library, but now I have the same error that @rrobinet talks about in a previous post, except that is marking 'rxififo'. This is the error at compile time: `` C:\Program Files (x86)\Arduino\hardware\espressif\esp32\cores\esp32\esp32-hal-uart.c:324:25: error: 'volatile union ' has no member named 'rxfifo' while(uart->dev->status.rxfifo.cnt != 0 || (uart->dev->mem_rx_status.wr_addr != uart->dev->mem_rx_status.rd_addr)) So what is the correct way to implement this patch? Thanks |
@zamorae the instead of Chuck. |
Hi Chuck @stickbreaker, Regards |
@me-no-dev @JacoFourie @PhilColbert @rrobinet @stickbreaker Gents, a) I can get messages from the client chips sent to the central/master chip but the central cannot reply back @PhilColbert @rrobinet @JacoFourie you state above that the patch is working correctly for you and that you have 100% comms on all 3 uarts and sfw reset. Can you provide a laundry list of things that need to be considered in order to get all the patch/modification correctly? I just wonder if I could be missing some of the steps. Check #1314 if you want to see an example of the code I'm using.
Let me know your thoughts. Thanks in advance! |
You should not expect serial.read to return the same data when called twice. You should not use flush with the patch to clear the RX buffer because you may discard unread data. |
Have you tested each UART on its own one by one using a test app? |
Here you can see my controller that I am porting to an ESP32. |
Yeah still working great for me, have a ereader on serial0, a custom built RF board on serial1 and a gps on serial2, all sending and receiving with no corruption, thankfully ! :) |
Guys, thanks for the support! I followed your recommendations, but I still can't understand why it's not working. I will share another sketch I defined that is not communicating correctly either, please point out any wrongdoing you find. I removed the flush() and the repeat Serial.write as mentioned by @negativekelvin. I am trying to achieve a echo test as proposed by @JacoFourie using only the ESP8266MOD and the central ESP32. using Serial 1 at (4,2) on the ESP32 and TX/RX as Serial1 on the ESP8266MOD, it seems that the ESP32 is echoing itself, even though I instructed to issue a different comment once the data is received from ESP32. I will share the sketch shortly. |
Hi everyone, Regards |
Hello guys,
arduino side
I want to use UART2 for a simple reason, UART0 doesn't work with the gsp module that I aim to use, i don't know why. Regards, |
All 2 UARTs work if you use the methods we showed above. |
@JacoFourie yeah, you're right. UART2 is working fine! Now I can send and receive data to and from esp32 with an Arduino UNO Wifi. The result "at" under "from CU" is an echo, I suppose. I wait for seconds but no one "OK" appear on the serial port. Regards, |
Break it down in smaller chunks. If you have it working on an Arduino then use just that code on a serial port that you know works on the ESP32 side. So get all the bits working on their own. Then you start to bring it together one by one as sometimes one thing will stop another from working. So break it down and the once you have it working them move it over. I also had an issue then I discovered I used the same pin of the screen reset as the data pin. |
@PhilColbert , @me-no-dev
or
generates
In summary; what should I do to have a Serial 2 (Pins 16 & 17) working with the new release. |
Serial1 and Serial2 are already defined so just skip to Serial2.begin |
Ok |
Description:
When I use all 3 UARTS they will all 3 send data. But I can not receive any data on the 3rd UART. I can read in serial0 and serial 1 but not on serial 2
Sketch:
This is just an code snippet.
Here is the paython code that is on the other side. Just for a test
Output on the serial monitor
Output on the Python Side
The text was updated successfully, but these errors were encountered: