[En-Nut-Discussion] UsartRead() may return false positives in cooked mode

Philipp Burch phip at hb9etc.ch
Wed Jan 7 22:40:25 CET 2015

Hi all,

I just discovered some strange behaviour when reading from a UART in
cooked mode if mixed end-of-line sequences are received. Consider this
example (assuming that some code on the Ethernut device is reading and
processing input from the UART):

Send a single LF to the device:

$ echo -en '\n' > /dev/ttyUSB0

Wait for the device to process the character, so that the receive buffer
is empty again. Now send a single CR to the device:

$ echo -en '\r' > /dev/ttyUSB0

Wait again until this has been processed.

This will make UsartRead() return with value 0, as the function expects
another character (everything except CR) but instead of waiting for it,
it just tells the caller that it got 0 characters.

r5982 in the devnut_tiva branch should fix this behaviour. The function
now loops until it actually placed some character in the buffer (or got
a timeout or error condition).


More information about the En-Nut-Discussion mailing list