IMU sample fetching over RS485

Hi,

I'm writing a program that will take the byte values put out by an IMU and perform the integrations to find position.

Right now, I am only concerned with how to properly recieve the data from the IMU. I can worry about the integrations and things later. The IMU will connect to my laptop via an RS422 port to USB converter for testing. Ultimately, it will be connected to a Linux processor board with a RS485 port.

The data stream from the IMU runs at 115200 Baud and each sample is 37 bytes long. The first four bytes are sync bytes, with a lot of other bytes with a 8-bit checksum at the end.

What I would like to do is to get a 37 byte sample starting at the synchronization bytes and first use the checksum to validate the data. Then I would like to strip away all of the bytes except for the Timer bytes, Gyro Bytes, Accelerometer Bytes and Magnetometer Bytes. Then I will store these bytes so that I can start the integrations.

This code will be part of a larger program later on so it cannot run within a while loop, but for now it would be fine for my testing purposes on my laptop. I don't need to get every sample coming over the serial port, I just need to make sure that I get a full sample and not partial.

I've done low datarate stuff over the RS232 port, but RS485 is different and this is a faster datarate. I am thinking about using some low priority interrupt to get a 37 byte sample every so often and store the byte values.

Does anyone know how I would approach this?

Thank you,
aloha_boi