Hello everybody
maybe I found a bug on the management of the RX input of the rs232 component, the jump to the macro for reading the input data is regulated by the RXINT2 interrupt, RX2 of the 232 is connected to a Nextion display that sends the bytes only once but the macro reads them for many times, I attach the test file and some screEnshoot
is this a bug or an error in my settings?
thank you
ESP32 WROOM RS232 PROBLEM
-
- Posts: 82
- http://meble-kuchenne.info.pl
- Joined: Thu Dec 10, 2020 5:40 pm
- Been thanked: 6 times
ESP32 WROOM RS232 PROBLEM
- Attachments
-
- Cattura_LI.jpg (52.26 KiB) Viewed 1907 times
-
- terminal.png (108.83 KiB) Viewed 1907 times
-
- ESP32_test_232.fcfx
- (25.46 KiB) Downloaded 156 times
-
- Matrix Staff
- Posts: 1901
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 494 times
- Been thanked: 668 times
Re: ESP32 WROOM RS232 PROBLEM
Hello,
The RX_232 interrupt macro should only be collecting a single byte, you are collecting 7. So the interrupt will fire 7 times but there is no data left after the first run because you have already collected all the bytes.
What would be better is to collect a single byte and add it into a circular buffer component. You can then in your main check for the number of bytes inside the circular buffer or search the buffer for valid responses.
The RX_232 interrupt macro should only be collecting a single byte, you are collecting 7. So the interrupt will fire 7 times but there is no data left after the first run because you have already collected all the bytes.
What would be better is to collect a single byte and add it into a circular buffer component. You can then in your main check for the number of bytes inside the circular buffer or search the buffer for valid responses.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: ESP32 WROOM RS232 PROBLEM
hello BenR
thanks for your answer, now I try your advice, but I can tell you that I have already used nextion on arduino mega2560 and I have never had this type of problem, maybe the interruput management between mega2560 and ESp32 is different?
thank you
thanks for your answer, now I try your advice, but I can tell you that I have already used nextion on arduino mega2560 and I have never had this type of problem, maybe the interruput management between mega2560 and ESp32 is different?
thank you
-
- Matrix Staff
- Posts: 1901
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 494 times
- Been thanked: 668 times
Re: ESP32 WROOM RS232 PROBLEM
Hello,
This is not the best way to do the interrupt though as you are essentially blocking the main task any any other high priority interrupts until you have received all 7 bytes.
Looks like ESP has a counter rather than a boolean flag and hence the 7 interrupts you are receiving even after collecting the data, the ESP must be expecting you to collect things a byte at a time. Doing it using the circular buffer is a much better approach as you are not blocking inside the interrupt while the other 6 bytes come in.
Waiting around for 6 bytes @ 9600 baud would equate to 6.25ms or approx 1,500,000 potentially wasted instructions on the ESP device.
Yes sorry it looks like it is, the mega only has a boolean interrupt flag and this is cleared when we leave the interrupt and so by that time all data has been received and processed and the interrupt does not fire again.maybe the interruput management between mega2560 and ESp32 is different?
This is not the best way to do the interrupt though as you are essentially blocking the main task any any other high priority interrupts until you have received all 7 bytes.
Looks like ESP has a counter rather than a boolean flag and hence the 7 interrupts you are receiving even after collecting the data, the ESP must be expecting you to collect things a byte at a time. Doing it using the circular buffer is a much better approach as you are not blocking inside the interrupt while the other 6 bytes come in.
Waiting around for 6 bytes @ 9600 baud would equate to 6.25ms or approx 1,500,000 potentially wasted instructions on the ESP device.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: ESP32 WROOM RS232 PROBLEM
Hi BenR
i did as you advised me and now i only read 7 bytes
thank you
i did as you advised me and now i only read 7 bytes
thank you
- Attachments
-
- Cattura.PNG (90.52 KiB) Viewed 1891 times