Serial reading and response with a microcontroller for hospital use

I am doing a project for my company, I would like to control the microcontroller that moves the motors of the hospital bed with the touch nextion. I have to practically read the serial data sent by the ECU and respond at the right time. the microcontroller sends a call signal every second and then the nextion display should automatically answer the call immediately after receiving the message.
On the display all this must not be seen, only the buttons for the various movements are displayed and these I managed to do them.
I tried reparse mode but I couldn’t.
Can anyone help me please?

Basically, reparse mode is the way to go. And there is no reason that it would not work when implemented correctly. But then, it depends on correct serial communication protocol between ECU and Nextion. The latter can only communicate using 8N1 protocol. If your ECU sends for example 9N2, it can not work.
To help you better, you’d have to share more details about the ECU, how it sends, what it sends, and what it expects in return.

thanks for your answer. it works like this: The ecu sends a series of calls to check the presence of the connected devices. ecu sends: 0xf0 0xf0 0x00 0x00 0x86 0x09 0x20 0x00 0x00 0x00 0x00 0x08 0x28 to this message nextion must reply: 0xC6 0xC6 0xFF 0x00 0x00 0x00 0x00 0x10 0x10 0x00 0x00. the ecu continuously sends this message and expects a response each time, so this must happen automatically without pressing any key. then pressing the keys to pilot an actuator nextion is limited only to send without receiving anything and then release the key and return to the initial condition. I am also willing to give you a small contribution for this information. thank you

What is the timeout for the Nextion to send the answer? How many milliseconds is the Nextion allowed to “think” before replying? At which data rate is the communication?

tomorrow I connect the logic analyzer and write you all the information you asked me. thank you

Meanwhile, I tell you that the baurate is 9600 and the original button panel responds to the call message of the ecu every 50ms, tomorrow I’ll tell you exactly.




the channel at the top is the ecu and the one at the bottom is the keypad that I have to replace.
as you can see the ecu calls the various peripherals connected, in this case there is a pushbutton panel connected for this only one answer arrives. I managed to remmod but didn’t understand how to loop reply to the specific address.

The reparse mode is the way to do it.
You need to set up a timer to keep checking the serial port for data.
Create a buffer variable to store the data from the serial port this enables you to parse the data.
Create global variables for the data so any screen can use them.
Once data is available stop that timer and enable another timer to read the data.
Read the data into the global variables.
Once the data has been read disable the timer and enable the serial port checking one again.
Note every screen needs the two timers.
By using timers nothing is seen on the screen just the results of what you want to see.
I have a Nextion sending commands to a power inverter , reading the data and displaying it with animation.

Have you read my post on the reparse mode?

Hi Paulvk, thank you for replying. I have seen your post I have already tried with the same procedure and the two timers. The problem is that to work in the nextion call it should dare to the response of the ecu every 488 ms approximately, then to analyze the input data I copy the 4 significant byte variable which I then display on the screen and then I set an if that goes to check if the value corresponds to the one I read with the logic analyzer, if the condition is true I print the message printh hex …
In repeating the cycle it happens that it reads the first byte of the call sequence but the second or the third or one in the middle for this reason I am not always able to verify the condition. If it is not clear I try to explain better.