Implementing tight time constraints for read/write with USB serial (ftdi_sio)

valdis.kletnieks at vt.edu valdis.kletnieks at vt.edu
Mon Sep 3 21:22:53 EDT 2018


On Mon, 03 Sep 2018 21:12:35 +0200, Thomas Bracht Laumann Jespersen said:

> The challenge is that my application needs to act within 100 tbits, ie in around
> ~.066ms. That is the window in which I need to begin transmitting a reply. Is
> there a way to achieve this with the ftdi_sio driver or do I need dedicated
> hardware for this?

(Hopefully you've already done all of the below - it's mostly for the
others out there thinking about doing real-time work...)

Step 0 is quantifying what a failure means.  Do you just miss a data point for
a graph, or does something on the assembly line explode or equally bad, or
something in between?

Step 1 is firming up exactly what that 0.66ms is.  Does it start at the
beginning of receiving the packet you care about, or when the last byte has
arrived?  And are you counting until the first byte of the response leaves, or
the last byte? Or are you counting until it's actually received at the target?
(Note that some statistical modeling may be needed, depending how PROFIBUS
behaves under load - what happens if another station is transmitting a very
large packet at the time you need to send your packet, etc etc..)

Step 2 is doing some userspace benchmarking of your response code - can the
target hardware do whatever processing is needed in the time allowed (remember
to subtract off any hardware-imposed latency like your PROFIBUS or your
RS485-USB converter).  This can be easy to meet if you have a beefy CPU and
just need to check the values of 3 bytes, add 2 other bytes together, and send
the result.  On the other hand, if you're on a low-end ARM and need to do a
512x512 FFT - the Realtime Gods may not smile favorably on your endeavor.

If your project is still alive at this point, *now* you start asking stuff like
realtime scheduling for your kernel thread, how to reduce interrupt
latency, and so on....

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 486 bytes
Desc: not available
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20180903/9a573f53/attachment.sig>


More information about the Kernelnewbies mailing list