Issue with read() and flush()
jeff.hatton at L3Harris.com
jeff.hatton at L3Harris.com
Thu Mar 2 21:57:52 UTC 2023
Hello,
I am working on a project that uses the RTEMS OS on a Leon3 processor. I am trying to read/write from a UART that is connected up through the termios interface. It works for the most part but I am running into an issue with flushing and reading from the UART. It seems if I read a small portion of the data use read() then flush then read again there is still data returned. Is this expected behavior? If so is there any way to clear out whatever is cached in read?
Pseudo Code
Open UART with open("/dev/console_b", O_RDWR | O_NONBLOCK); setup terminal into raw mode with cfmakeraw() and tcsetattr(fd,
TCSADRAIN,term)
Setup the UART into loop back mode so its TX data is looped back into its RX Write data into UART with write(fd, "TEST",4) Read a single character with read(fd, buff, 1); buff will contain "T" here flush buffers with tcflush(fd, TCIOFLUSH) Read a more from UART with read(fd, buff, 3); Would expect nothing is returned here but "EST" will be returned.
Jeff Hatton
CONFIDENTIALITY NOTICE: This email and any attachments are for the sole use of the intended recipient and may contain material that is proprietary, confidential, privileged or otherwise legally protected or restricted under applicable government laws. Any review, disclosure, distributing or other use without expressed permission of the sender is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies without reading, printing, or saving.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20230302/fa44a009/attachment.htm>
More information about the users
mailing list