Trouble reading from the RV50 serial port

If bytes were corrupted I would think of a hardware issue (bad cable for instance).
For misalignment issue, it could be caused by the timeout, the way you read your data. In general I do not recommend using “*a” pattern + timeout. for normal reading on the serial port. It is usually better to read the number of bytes you actually need.
A typical algorithm:

  1. Phase one: read each byte one by one (serial:receive(1)), until a synchronization pattern is found
  2. Phase two: read a frame with the exact byte count. Some time the frame is variable size, in that case I read the minimum number, parse it and infer the rest of the frame size (for instance if the frame size is in the packet header)

Another note: I have found that closing/reopening the serial port while reading does cause some weird data to be read, so make sure you do not close/open the serial port during the receive operation.