I have a development board that runs some Linux distribution, this board has some UART
peripherals that are mapped into the system as a tty
-like files.
On a specific UART
port I have connected a LIN
* transceiver which is connected to a LIN
bus.
The LIN
transceiver outputs me frames (two types: one type of frame has 3 bytes
, and the other one has between minimum 6 bytes
and maximum 12 bytes
) with a minimum ~20ms
of distance between them.
Now I want to write an application that is able to read this individual frames as data buffers (not byte-by-byte or any other possibility).
For setting the communication parameters (baud rate, parity bits, start/stop bits, etc), I'm using the stty
** utility. I have played a bit with the min
, and time
[***] special settings parameters, but I didn't obtained the right behavior, big frames will always be spitted into at least three chunks.
Is there any way to achieve this?
[*] LIN: https://en.wikipedia.org/wiki/Local_Interconnect_Network
[**] stty: http://linux.die.net/man/1/stty
[***] I have used the following modes:
MIN == 0, TIME > 0 (read with timeout)
This won't work because I will always receive at least one individual byte (and the rest of the frame as a buffer).
MIN > 0, TIME > 0 (read with interbyte timeout)
In this mode setting the MIN
to 3 (the smallest frame haves 3 bytes), and the TIME
parameter to some higher value like 90 also won't do the trick, the short frames are received correctly in this case (at once), but the longer frames are splitted into 3 parts (the first part with 3 bytes, the second one with three bytes, and the last one with 5 bytes).