serialEvent() question

Hello,

I am developping a project for my bachelor's thesis.

There will be bitstreams incoming via RS-422 interface and manipulated, which I already have written working code for and soldered some ICs (and capacitors etc.).

I will be using three Arduinos in total, one UNO, one Mega and one Ethernet. Each will communicate with the others via UART.

Now my question:

Since I am having rarely appearing errors with communicating between the three Arduinos via UART, I think the serialEvent() function might be the problem.

Can someone tell me when exactly the serialEvent() function is called? I mean is it called always after the loop(), or does it use interrupts, that could happen while processing code in the loop()?

Thank you and best regards :slight_smile:

/*
SerialEvent occurs whenever a new data comes in the
hardware serial RX. This routine is run between each
time loop() runs, so using delay inside loop can delay
response. Multiple bytes of data may be available.
*/

I don't like serialEvent(). I prefer to use if (Serial.available() > n) { when it suits me to do so. That way I can, for example, wait until there are several characters in the buffer before dealing with any of them.

But without seeing your code it is impossible to give detailed advice.

For the sort of system you describe you probably need to take some trouble to design the communication system to minimize the load.

...R