Hello community,
I am using an i.mx6ull with Linux for reading data over UART5 (/dev/ttymxc4).
I need to set a system timestamp for incoming data that should be of precision < 1ms.
What is the best way to read from UART and get fastest handling of incoming data to set most accurate timestamp?
So far I have done:
Linux Kernel is 5.10.76 with the PREEMPT_RT patch applied.
Set priority of kernel task 'irq/21f4000' to 98 for fast interrupt handling.
I set CPUIDLE states1 and state2 to disabled for fast wakeup.
CPU scaling govenor is set to userspace with max frequency 792 MHz.
I did setserial /dev/ttymxc4 low_latency
I have an user space task that runs at priority 98 for reading the data.
Basically all works fine and I get an accuracy of 50 µs standard deviation. But sometimes also slightly over 1 ms. I want to improve this to get below 1 ms.
Pseudo code of the reading task:
ttymxc4_fd = ::open("/dev/ttymxc4", O_RDWR | O_NOCTTY | O_NDELAY);
struct pollfd = pollSrc;
pollSrc.fd = ttymxc4_fd;
pollSrc.events = POLLIN;
pollfd.revents = 0;
...
while(true)
{
poll(&pollSrc, 1)
clock_gettime(CLOCK_REALTIME, &recvTimestamp);
read(ttymxc4_fd, read_buf, sizeof(read_buf));
...
}Any advice for improving that? Thank you in advance.