I have a time-sensitive C program that performs serial port I/O with microsecond-level precision. The program currently works well and meets our requirements. I have two questions:
- Would there be any significant advantages to rewriting this program in Rust, particularly in terms of performance or reliability for such precise timing operations?
- Currently, the program writes the data it reads from the serial port to an ASCII file. A separate Qt application launches this C program and displays the current file size. We now need to modify the system so that the Qt application can also display the contents of the data being read at 1 or 2 seconds periodicity. What would be the most efficient way to implement this inter-process communication between the C program and the Qt application?
Additional context:
- The target OS is Yocto Linux
- The C program is responsible for data acquisition from the serial port.
- The timing requirements are very strict (microsecond level). This means,
- The program needs to send commands and read responses at very specific, short intervals (measured in millionths of a second).
- It uses high-precision timing functions to measure and control these intervals.
- The code tries to maintain consistent timing between operations, adjusting for any delays.
- It uses real-time scheduling to ensure the program gets immediate CPU attention when needed.
- The system needs to remain responsive and efficient.
I’d appreciate insights on both the potential benefits of a Rust rewrite and recommendations for implementing the new IPC requirement with Qt. Thanks in advance!
I haven’t tried rewriting the program in Rust yet. My current C program is working as expected, meeting the microsecond-level precision requirements for serial port communication.
What I’ve tried:
- Implemented the program in C with real-time scheduling and high-precision timing functions.
- Used techniques like setpriority() and sched_setscheduler() to ensure high priority execution.
- Employed clock_gettime() with CLOCK_MONOTONIC_RAW for accurate time measurements.
- Utilized usleep() for precise timing control between operations.
What I’m expecting:
- I’m curious if Rust could provide any performance improvements or added reliability for this kind of time-sensitive operation.
- I’m wondering if Rust’s safety features might be beneficial without sacrificing the precise timing control I currently have in C.
- I’m interested in learning if Rust has any specific advantages for systems programming tasks that require such tight timing constraints.
You need to sign in to view this answers