JY901.cpp
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "JY901.h"
5 
7 {
8 }
9 
10 void CJY901::FetchData(char *data, int usLength)
11 {
12  char *pData_head = data;
13  while (usLength >= 11)
14  {
15  if (pData_head[0] != 0x55)
16  {
17  pData_head++;
18  continue;
19  }
20  switch (pData_head[1])
21  {
22  case 0x50:
23  memcpy(&stcTime, &pData_head[2], 8);
24  break;
25  case 0x51:
26  memcpy(&stcAcc, &pData_head[2], 8);
27  acc.x = stcAcc.a[0] / 32768.00 * 16 * 9.8;
28  acc.y = stcAcc.a[1] / 32768.00 * 16 * 9.8;
29  acc.z = stcAcc.a[2] / 32768.00 * 16 * 9.8;
30  break;
31  case 0x52:
32  memcpy(&stcGyro, &pData_head[2], 8);
33  gyro.x = stcGyro.w[0] / 32768.00 * 2000 / 180 * 3.1415926;
34  gyro.y = stcGyro.w[1] / 32768.00 * 2000 / 180 * 3.1415926;
35  gyro.z = stcGyro.w[2] / 32768.00 * 2000 / 180 * 3.1415926;
36  break;
37  case 0x53:
38  memcpy(&stcAngle, &pData_head[2], 8);
39  angle.r = stcAngle.Angle[0] / 32768.00 * 3.1415926;
40  angle.p = stcAngle.Angle[1] / 32768.00 * 3.1415926;
41  angle.y = stcAngle.Angle[2] / 32768.00 * 3.1415926;
42  break;
43  case 0x54:
44  memcpy(&stcMag, &pData_head[2], 8);
45  mag.x = stcMag.h[0];
46  mag.y = stcMag.h[1];
47  mag.z = stcMag.h[2];
48  break;
49  // case 0x55: memcpy(&stcDStatus,&chrTemp[2],8);break;
50  // case 0x56: memcpy(&stcPress,&chrTemp[2],8);break;
51  // case 0x57: memcpy(&stcLonLat,&chrTemp[2],8);break;
52  // case 0x58: memcpy(&stcGPSV,&chrTemp[2],8);break;
53  case 0x59:
54  // printf("\n0x59 Source Data is : { %#.2X %#.2X %#.2X %#.2X %#.2X %#.2X %#.2X %#.2X }", chrTemp[2], chrTemp[3], chrTemp[4], chrTemp[5], chrTemp[6], chrTemp[7], chrTemp[8], chrTemp[9]);
55  memcpy(&stcQuat, &pData_head[2], 8);
56  // printf("\nSource Data is : { x: %d y: %d z: %d w: %d}", stcQuat.q[1], stcQuat.q[2], stcQuat.q[3], stcQuat.q[0]);
57  quat.w = stcQuat.q[0] / 32768.00;
58  quat.x = stcQuat.q[1] / 32768.00;
59  quat.y = stcQuat.q[2] / 32768.00;
60  quat.z = stcQuat.q[3] / 32768.00;
61  break;
62  }
63  usLength -= 11;
64  pData_head += 11;
65  }
66 }
Gyro gyro
Definition: JY901.h:192
Angle angle
Definition: JY901.h:193
double z
Definition: JY901.h:162
double z
Definition: JY901.h:155
double p
Definition: JY901.h:168
double x
Definition: JY901.h:174
double x
Definition: JY901.h:153
double z
Definition: JY901.h:176
struct S_Angle stcAngle
Definition: JY901.h:204
short a[3]
Definition: JY901.h:89
double y
Definition: JY901.h:182
double w
Definition: JY901.h:184
struct Acc acc
Definition: JY901.h:191
double y
Definition: JY901.h:175
double x
Definition: JY901.h:181
struct S_Mag stcMag
Definition: JY901.h:205
double z
Definition: JY901.h:183
struct S_Acc stcAcc
Definition: JY901.h:202
short Angle[3]
Definition: JY901.h:101
double x
Definition: JY901.h:160
double y
Definition: JY901.h:161
struct S_Quat stcQuat
Definition: JY901.h:210
double r
Definition: JY901.h:167
short h[3]
Definition: JY901.h:107
short w[3]
Definition: JY901.h:95
void FetchData(char *data, int usLength)
Definition: JY901.cpp:10
struct S_Gyro stcGyro
Definition: JY901.h:203
Mag mag
Definition: JY901.h:194
struct S_Time stcTime
Definition: JY901.h:201
Quat quat
Definition: JY901.h:195
double y
Definition: JY901.h:154
CJY901()
Definition: JY901.cpp:6
double y
Definition: JY901.h:169
short q[4]
Definition: JY901.h:137


wit-imu-driver
Author(s): Inspur Group, Penn Zhang
autogenerated on Fri Sep 4 2020 03:48:11