I need to send and receive an Ethercat frame every millisecond.
In my customized operating system, RT patches have been enabled. I have a thread that sends a frame and the second thread that receives frames. The network is Ethercat so when I send the frame this is modified on the fly and I receive it instantly. Both threads are configured as SCHED_FIFO and RT priority. The first thread sends the frame and is suspended on semaphore. The semaphore will be freed from the second thread when the frame is received.
- get time start
- send frame
- wait semaphore
- get time end
- wait until to 1 millisecond
- wait Ethercat frame
- free semaphore
Normally I have a time (end time - start time) of about 600usec between sending and receiving (I can wait for 400usec), but sometimes I have 1.5msec frames. How can I avoid these 1.5 msec frames? Is there a way to increase the priority of the IRQ and / or interrupt thread? Do you have any advice?
PS: I don’t have any applications with UI, but for now in my image there is LXDE. In addition to system ones, I have no other applications.