Hi to all,
I need to read data from an old sensor which use a serial port to send packets.
I think it would be better for me to use C/C++ under Ubuntu.
In the sensor manual, packet format is explained in this way:
Each data packet begins with a header byte (255) and end with a
checksum. The checksum is calculated in the following manner:
1. Sum all packet contents except header and checksum.
2. Divide the sum by 256.
3. The remainder should equal the checksum.
The header byte 0xFF will likely not be the only 0xFF byte in the data
packet. You must count the bytes received at your serial port and use the
checksum to ensure you are in sync with the data sent by the DMU. This is
especially critical when using the continuous data packet output mode.
I attached to this topic a table with all fields contained in a single packet.
I also have a matlab code which is able to read the packet, but I'm not able to understand what it does.
o1sc(1:2,1)=o1(1:2,1)*sfan; % (deg) Roll and Pitch
o1sc(3:5,1)=o1(3:5,1)*sfr; %deg/s Tilt rate
o1sc(6:8,1)=o1(6:8,1)*sfa; % g accelerations
o1sc(9,1)=((o1(9,1) * 5/4096)-1.375)*44.44; % Temperature (8C)
x = int16(o1(10,1));
if x < 0
y = uint16(double(x) + 65536);
y = uint16(x);
Can someone explain me what the matlab code do, please?
I do not know how to translate it in C code, unfortunately.
Any tips and suggestions are really appreciate!! :)