Reading UART from other sensors


I am attempting to integrate some other sensors to use in conjunction with the PX4 system. I have the dev environment setup and have built various modules which run from the shell. These sensors are UART based, and I am having trouble finding information on the forums and docs as to the proper techniques to acquire UART data.

So far I am able to initialize a UART port, set the baud rate and settings, and even send characters over the UART to a terminal. I was wondering what the best way to capture UART data is. I have found ::read(…) function to acquire single bytes from the buffer. Is there a mechanism built in to automatically execute callbacks when data is received/ buffer is full? How can I query the buffer size for a UART?

For example, I have a sensor which sends out 32 bytes with a terminating character ten times a second. Do I have to manually read the buffer byte by byte and compile the UART string based on finding the termination characters? Or are there functions within PX4 which I can assign callbacks from? Depending on the OS I assume that I may not be able to read the buffer byte by byte in real time when operating as a deamon task. Do I just incrementally read the buffer byte by byte every time my function executes?

Thanks in advance!

1 Like

Are you able to figure it out? Please help me in this regard.

Were you able to figure it out?