I got a Raspberry Pi 4 processing Lidar data (RPLIDAR S2) with python (PySerial library). The lidar sends data in chunks of about 50-60 bytes at 1000000 bps over serial. When I use a USB Serial FTDI dongle that comes with a lidar, I can easily read data, buffer easily holds them until read. However, my robot should be compact, so I want to eliminate the dongle and the extra USB cable, so I tried to connect the lidar directly to the GPIO and connect using the UART /dev/ttyS0. I can set up the connection, read lidar info, and order it to start - these data are only a few bytes long. The problem is, when I start sending data using 50-byte chunks, I get errors - the buffer is smaller than the chunks which I am trying to read at once...
Which would be the solution? Is it possible to increase the buffer size on the OS level or PySerial? Stuck here...