282 static const Byte COMMAND_BYTE = 0xCE;
285 static const int RESPONSE_SIZE = 19;
286 Byte response[RESPONSE_SIZE] = {0};
287 int size =
readComPort(comPort, &response[0], RESPONSE_SIZE);
293 if(size != RESPONSE_SIZE)
295 cerr <<
"Invalid response size" << endl;
300 if(response[0] != COMMAND_BYTE)
302 cout << response[0] << COMMAND_BYTE << endl;
303 cerr <<
"Invalid response" << endl;
308 short responseChecksum =
convert2ushort(&response[RESPONSE_SIZE-2]);
311 if(calculatedChecksum != responseChecksum)
313 cerr <<
"calculatedChecksum" << calculatedChecksum << endl;
314 cerr <<
"responseChecksum" << responseChecksum << endl;
315 cerr <<
"Invalid Checksum" << endl;
320 static const float SCALE_AS_DEGREES = 180.0/
PI;
int readComPort(ComPortHandle comPort, Byte *bytes, int bytesToRead)
Definition: test_imu.cpp:246
unsigned short i3dmgx2_Checksum(const unsigned char *pBytes, int count)
Definition: test_imu.cpp:127
unsigned char Byte
Definition: test_imu.cpp:41
int writeComPort(ComPortHandle comPort, const Byte *bytesToWrite, int size)
Definition: test_imu.cpp:256
float FloatFromBytes(const unsigned char *pBytes)
Definition: test_imu.cpp:97
float roll
Definition: test_imu.cpp:271
float pitch
Definition: test_imu.cpp:272
#define PI
Definition: test_imu.cpp:37
unsigned short convert2ushort(unsigned char *buffer)
Definition: test_imu.cpp:79
float yaw
Definition: test_imu.cpp:273