Hello,
I am trying to get an OpenMV H7 Plus board to read values off of the LD06 lidar. Since the lidar can only communicate with the OpenMV H7 Plus board through UART, I followed the instructions of the documentation and connected the lidar to the P4 and P5 pins of the OpenMV H7 Plus board. While I am able to read the correct values off of the LD06 lidar, I am not reading all of the data that I expected. More specifically, I am expecting that the lidar writes data into a buffer, and the OpenMV H7 Plus reads data off of the buffer one byte at a time (the buffer would be flushed under certain conditions). However, the OpenMV H7 Plus seems to be flushing the buffer after reading one byte of data every time serial.read(1)
is called. I have written the same code (but using CPython) on a Raspberry Pi Zero 2 and was able to read the values one byte at a time in sequence as I expected. Since being able to read all the data and having all the data in sequence are important for my project, please provide any possible solutions to the problem. My code is as follows.
from pyb import UART
serial = UART(3)
serial.init(baudrate=230400, bits=8, parity=None, stop=1)
while True:
if serial.any():
read_byte = serial.read(1)
else:
continue
print(read_byte)
Thank you!
Thomas