UART Api - reading single byte, reading single line, peeking into the driver buffer
Posted: Thu Apr 23, 2020 9:33 pm
Hi, i'd like to user the uart driver APIs to read text from serial port, line by line. So i need an api function to look inside the receive buffer and check if a line end character is in the buffer. But it seems we only have function that reads a fixed number of bytes regardless of the buffer content. So to use it for reading line by line i would have to use uart_read_bytes to read single characters in a loop, until line break is found.
Of course I could do that but it appears quite inefficient as uart_read_bytes is quite complex function that's not optimized for single byte reading. So, question to you - is there anything i could use for efficient line by line uart processing?
And btw i dont want to implement another level of buffering in my code, i'd prefer to use standard UART APIs and its internal buffer.
Thanks
R
Code: Select all
uart_read_bytesOf course I could do that but it appears quite inefficient as uart_read_bytes is quite complex function that's not optimized for single byte reading. So, question to you - is there anything i could use for efficient line by line uart processing?
And btw i dont want to implement another level of buffering in my code, i'd prefer to use standard UART APIs and its internal buffer.
Thanks
R