Hi @Fjodor, well I have a buffer longer than the message that is going to receive, since I’m not using an arduino but an STM32 microcontroller I had to adapt the libraries, the ST people offers their own HAL libraries to manage peripherals and I’m using in this case the one to comunicate through serial port. The serial libraries of ST uses a fixed quantity of bytes as arguments to transmit and/or receive, that part is working well but for what I saw the HMI doesn’t make a pause between the confirmation message and the event sending to the main microcontroller, so, if I instruct the main microcontroller to receive the confirmation message plus the event message it fails for timeout almost all the time because an event on the HMI happens rarely compared tho the quantity of confirmation messages that the HMI sends back to the main microcontroller; then, If I instruct the main microcontroller to receive only the quantity of bytes equivalent to the confirmation message and after that I instruct the main microcontroller to receive the event message then it fails to because apparently it can reconfigure the function soon enough to receive the event message and also the main microcontroller doesn’t know when an event message is coming so the error comes again. Another thing that I noted is that also aparently the HAL function doesn’t write the received bytes directly in the destination buffer but stores them in an temporary buffer so even when I tried to cut the function just after it received the three 0xff the received data is lost because the HAL receive function doesn’t receive the complete number of bytes. Thats why I’m asking if there is a way to force the HMI to wait a minimal amount of time after the confirmation message is sent to send the event message.
I also need to clarify that the receive function that I’m using is a blocking one, it means that it doesn’t use interrupts to work and I’m using it because is the only function in the library that has a timeout to force out the function if the function itself hasn’t received the complete amount of bytes in that time, ther are others with interrupts but I have to force the timeout by putting external conditions since they doesn’t have a timeout argument and internally they have the same kind of temporary buffer so I think I’ll have the same outcome using the interrupt functions.
That’s why I’m asking if there is possible to force the HMI to wait some time after send the confirmation message to send the event message.