-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGPSLassen.h
executable file
·278 lines (209 loc) · 8.03 KB
/
GPSLassen.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA *
* *
***************************************************************************
* *
* (c) Copyright, 1997-2012, ANSR *
* *
***************************************************************************
* *
* Filename: GPSLassen.h *
* *
***************************************************************************/
#ifndef GPSLASSEN_H
#define GPSLASSEN_H
/**
* @defgroup external External Peripherals
*
* @{
*/
/**
* Read and process the GPS Binary messages from the Trimble Lassen
* GPS engine.
*/
class GPSLassen
{
public:
GPSLassen();
GPSData *Data();
bool_t IsDataReady();
void Update();
const char *Version();
/**
* Callback to determine if the there is serial data to process from the GPS engine.
*
* @return true if data is in FIFO; otherwise false
*/
virtual bool_t HasData();
/**
* Callback to read the oldest serial data from the GPS engine.
*
* @return oldest byte from serial FIFO
*/
virtual uint8_t ReadData();
/**
* Callback to write serial data to the GPS engine.
*
* @param data 8-bit data to write
*/
virtual void WriteData(uint8_t data);
static GPSLassen *GetInstance();
private:
/// The maximum length of a binary GPS engine message.
static const uint32_t GPSBufferSize = 80;
/// Number of bytes in the software version string.
static const uint32_t VersionSize = 80;
/// Number of seconds per week. 60 seconds/minute * 60 minutes/hour * 24 hours/day * 7 days/week.
static const uint32_t SecondsPerWeek = 604800;
/// TSIP packet start/end head
static const uint32_t DLE = 0x10;
/// TSIP data packet tail
static const uint32_t ETX = 0x03;
/// GPS parse engine state machine values.
typedef enum
{
MSG_IN_COMPLETE,
TSIP_DLE,
TSIP_IN_PARTIAL
} GPS_PARSE_STATE_MACHINE;
/// Report Packet 0x41 - GPS Time
typedef struct __attribute__ ((__packed__))
{
/// Always 0x41 for this message.
uint8_t messageID;
/// GPS time of week in seconds.
float_t timeOfWeek;
/// GPS extended week Number.
uint16_t weekNumber;
/// GPS UTC Offset (seconds).
float_t utcOffset;
} GPS_TIME_PACKET;
/// Report Packet 0x45 - Software Version Information
typedef struct __attribute__ ((__packed__))
{
/// Always 0x45 for this message.
uint8_t messageID;
/// Major version number for navigation processor.
uint8_t navMajorVersionNumber;
/// Minor version number.
uint8_t navMinorVersionNumber;
/// Month.
uint8_t navMonth;
/// Day.
uint8_t navDay;
/// Year number minus 1900.
uint8_t navYear;
/// Major version number for signal processor.
uint8_t sigMajorVersionNumber;
/// Minor version number.
uint8_t sigMinorVersionNumber;
/// Month.
uint8_t sigMonth;
/// Day.
uint8_t sigDay;
/// Year number minus 2000.
uint8_t sigYear;
} GPS_SOFTWARE_VERSION_PACKET;
/// Report Packet 0x46 - Health of Receiver
typedef struct __attribute__ ((__packed__))
{
/// Always 0x46 for this message.
uint8_t messageID;
/// Status Code in the range 0x00 to 0x0c.
uint8_t statusCode;
/// Battery and antenna status bitmap.
uint8_t batteryAntennaStatus;
} GPS_RECEIVER_HEALTH_PACKET;
/// Report Packet 0x4A - 20 Byte Format
typedef struct __attribute__ ((__packed__))
{
/// Always 0x4A for this message.
uint8_t messageID;
/// Latitude in radians.
float_t latitude;
/// Longitude in radians.
float_t longitude;
/// Altitude in meters (HAE or MSL).
float_t altitude;
/// Clock bias in meters.
float_t clockBias;
/// Time of fix in seconds (GPS or UTC),
float_t timeOfFix;
} GPS_LLA_PACKET;
/// Report Packet 0x56 - Velocity Fix, East-North-Up (ENU).
typedef struct __attribute__ ((__packed__))
{
/// Always 0x56 for this message.
uint8_t messageID;
/// East velocity in m/s; + for east, - for west.
float_t eastVelocity;
/// North velocity in m/s; + for north, - for south.
float_t northVelocity;
/// Up velocity in m/s; + for up, - for down.
float_t upVelocity;
/// Clock bias rate in m/s.
float_t clockBiasRate;
/// Time of Fix in seconds (GPS or UTC).
float_t timeOfFix;
} GPS_VELOCITY_FIX_PACKET;
/// Report Packet 0x6D - All-In-View Satellite Selection
typedef struct __attribute__ ((__packed__))
{
/// Always 0x6d for this message.
uint8_t messageID;
/// Dimension
uint8_t dimension;
/// PDOP.n
float_t pdop;
/// HDOP.
float_t hdop;
/// VDOP.
float_t vdop;
/// TDOP.
float_t tdop;
/// Array of SV PRNs in solution.
uint8_t svPRN[16];
} GPS_ALL_IN_VIEW_PACKET;
void ParseMessage();
void ProcessGPSTimePacket (const GPS_TIME_PACKET *packet);
void ProcessAllInViewPacket(const GPS_ALL_IN_VIEW_PACKET *packet);
void ProcessLLAPacket (const GPS_LLA_PACKET *packet);
void ProcessVelocityFix (const GPS_VELOCITY_FIX_PACKET *packet);
void ProcessReceiverHealth (const GPS_RECEIVER_HEALTH_PACKET *packet);
void ProcessSoftwareVersion (const GPS_SOFTWARE_VERSION_PACKET *packet);
void TimeOfWeek(uint32_t timeOfWeek);
uint16_t UInt16GPSToHost (uint16_t value);
uint32_t Uint32GPSToHost (uint32_t value);
float_t FloatGPSToHost (float_t nLongNumber);
/// Object that stores the current GPS fix data.
GPSData data;
/// Index into gpsBuffer used to store message data.
uint32_t gpsIndex;
/// GPS Time of Week in seconds.
uint32_t timeOfWeek;
/// Offset in seconds between GPS and UTC time.
uint32_t utcOffset;
/// State machine used to parse the GPS message stream.
GPS_PARSE_STATE_MACHINE gpsParseState;
/// Buffer to store data as it is read from the GPS engine.
uint8_t gpsBuffer[GPSBufferSize];
/// Buffer to store the software version.
char version[VersionSize];
/// Flag that is set when a data set has been parsed.
bool_t dataReadyFlag;
};
/** @} */
#endif // #ifndef GPSLASSEN_H