dispatch.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2015-2020, Dataspeed Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Dataspeed Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #ifndef _DISPATCH_H
36 #define _DISPATCH_H
37 #include <stdint.h>
38 
39 #pragma pack(push, 1)
40 typedef union {
41  uint8_t bytes[8];
42  struct {
43  uint32_t gps_minutes;
44  uint8_t num_sats;
45  uint8_t position_mode;
46  uint8_t velocity_mode;
48  } chan0;
49  struct {
50  uint16_t acc_position_north; // 1e-3 m
53  uint8_t age;
54  } chan3;
55  struct {
56  uint16_t acc_velocity_north; // 1e-3 m/s
59  uint8_t age;
60  } chan4;
61  struct {
62  uint16_t acc_heading; // 1e-5 rad
63  uint16_t acc_pitch;
64  uint16_t acc_roll;
65  uint8_t age;
66  } chan5;
67  struct {
69  int8_t base_station_id[4];
70  } chan20;
71  struct {
72  uint16_t delay_ms;
73  } chan23;
74  struct {
75  uint8_t heading_quality; // 0:None 1:Poor 2:RTK Float 3:RTK Integer
76  } chan27;
77  struct {
78  int16_t heading_misalignment_angle; // 1e-4 rad
79  uint16_t heading_misalignment_accuracy; // 1e-4 rad
80  uint16_t :16;
81  uint8_t valid;
82  } chan37;
83  struct {
84  int16_t undulation; // 5e-3 m
85  uint8_t HDOP; // 1e-1
86  uint8_t PDOP; // 1e-1
87  } chan48;
88 } Channel;
89 typedef struct {
90  uint8_t sync;
91  uint16_t time;
92  int32_t accel_x :24; // 1e-4 m/s^2
93  int32_t accel_y :24; // 1e-4 m/s^2
94  int32_t accel_z :24; // 1e-4 m/s^2
95  int32_t gyro_x :24; // 1e-5 rad/s
96  int32_t gyro_y :24; // 1e-5 rad/s
97  int32_t gyro_z :24; // 1e-5 rad/s
98  uint8_t nav_status;
99  uint8_t chksum1;
100  double latitude;
101  double longitude;
102  float altitude;
103  int32_t vel_north :24; // 1e-4 m/s
104  int32_t vel_east :24; // 1e-4 m/s
105  int32_t vel_down :24; // 1e-4 m/s
106  int32_t heading :24; // 1e-6 rad
107  int32_t pitch :24; // 1e-6 rad
108  int32_t roll :24; // 1e-6 rad
109  uint8_t chksum2;
110  uint8_t channel;
112  uint8_t chksum3;
113 } Packet;
114 enum {
118  MODE_SPS = 3,
146  MODE_PPP = 31,
148 };
149 #pragma pack(pop)
150 
151 static bool validatePacket(const Packet *packet) {
152  if (packet->sync == 0xE7) {
153  const uint8_t *ptr = (uint8_t*)packet;
154  uint8_t chksum = 0;
155  for (unsigned int i = 1; i < sizeof(Packet) - 1; i++) {
156  chksum += ptr[i];
157  }
158  return chksum == packet->chksum3;
159  }
160  return false;
161 }
162 
163 static_assert(8 == sizeof(Channel), "");
164 static_assert(72 == sizeof(Packet), "");
165 
166 #endif // _DISPATCH_H
int16_t undulation
Definition: dispatch.h:84
uint16_t acc_roll
Definition: dispatch.h:64
uint16_t acc_position_down
Definition: dispatch.h:52
int16_t base_station_age
Definition: dispatch.h:68
uint16_t delay_ms
Definition: dispatch.h:72
uint8_t heading_quality
Definition: dispatch.h:75
uint16_t acc_position_north
Definition: dispatch.h:50
uint8_t age
Definition: dispatch.h:53
uint32_t gps_minutes
Definition: dispatch.h:43
uint8_t channel
Definition: dispatch.h:110
uint16_t acc_velocity_east
Definition: dispatch.h:57
uint8_t velocity_mode
Definition: dispatch.h:46
uint8_t chksum2
Definition: dispatch.h:109
double latitude
Definition: dispatch.h:100
static bool validatePacket(const Packet *packet)
Definition: dispatch.h:151
uint8_t nav_status
Definition: dispatch.h:98
uint16_t acc_position_east
Definition: dispatch.h:51
uint8_t HDOP
Definition: dispatch.h:85
double longitude
Definition: dispatch.h:101
int16_t heading_misalignment_angle
Definition: dispatch.h:78
uint16_t acc_heading
Definition: dispatch.h:62
uint8_t PDOP
Definition: dispatch.h:86
uint16_t acc_velocity_down
Definition: dispatch.h:58
uint16_t acc_velocity_north
Definition: dispatch.h:56
uint16_t heading_misalignment_accuracy
Definition: dispatch.h:79
uint8_t position_mode
Definition: dispatch.h:45
uint16_t acc_pitch
Definition: dispatch.h:63
uint8_t num_sats
Definition: dispatch.h:44
uint8_t sync
Definition: dispatch.h:90
uint8_t valid
Definition: dispatch.h:81
uint8_t chksum3
Definition: dispatch.h:112
uint8_t chksum1
Definition: dispatch.h:99
uint16_t time
Definition: dispatch.h:91
float altitude
Definition: dispatch.h:102
Channel chan
Definition: dispatch.h:111
uint8_t orientation_mode
Definition: dispatch.h:47


oxford_gps_eth
Author(s): Kevin Hallenbeck
autogenerated on Sun Aug 9 2020 04:05:34