Copernicus
1.0
An Arduino module for the Trimble Copernicus GPS receiver
Main Page
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Enumerations
Enumerator
Friends
Macros
Groups
copernicus
copernicus.h
Go to the documentation of this file.
1
/*
2
* File: copernicus.h
3
* Author: tbabb
4
*
5
* Created on October 5, 2013, 10:35 PM
6
*
7
* Note: It would be entirely possible, and not difficult, to extract
8
* this module's dependency on the Arduino by replacing m_serial with
9
* any reasonable buffered serial IO class.
10
*/
11
12
//TODO: support GPS time
13
//TODO: add commands
14
//TODO: fixp support
15
16
#ifndef COPERNICUS_H
17
#define COPERNICUS_H
18
19
#define CTRL_DLE 0x10
20
#define CTRL_ETX 0x03
21
32
// arduino doesn't support std::vector
33
// so today we will be violating the zero/one/infinity rule.
34
#define MAX_PKT_PROCESSORS 8
35
36
#define TSIP_BAUD_RATE 38400
37
38
#include "
gpstype.h
"
39
#include "Arduino.h"
40
41
class
CopernicusGPS
;
// fwd decl
42
43
/***************************
44
* Listener class *
45
***************************/
46
56
class
GPSPacketProcessor
{
57
public
:
58
virtual
~GPSPacketProcessor
();
59
71
virtual
PacketStatus
gpsPacket
(
ReportType
type,
CopernicusGPS
*gps) = 0;
72
};
73
74
/***************************
75
* copernicus class *
76
***************************/
77
78
// - what does the fix time mean / how does it relate to GPS time?
79
// - the fix time is the time at which the fix was acquired. it will generally
80
// be a few seconds in the past. Use your sync'd current GPS time
81
// to figure out how that relates to "now".
82
// - how does the GPS time relate to the last/next PPS?
83
// - reported GPS time is that of the last PPS. So at the next
84
// PPS pulse, add 1 to the captured GPS time, and that's the current time.
85
89
class
CopernicusGPS
{
90
public
:
91
CopernicusGPS
(
int
serial=0);
92
93
ReportType
processOnePacket
(
bool
block=
false
);
94
void
waitForPacket
(
ReportType
type);
95
96
void
beginCommand
(
CommandID
cmd);
97
void
writeDataBytes
(
const
uint8_t *bytes,
int
n);
98
int
readDataBytes
(uint8_t *dst,
int
n);
99
void
endCommand
();
100
101
bool
setFixMode
(
ReportType
pos_fixmode,
102
ReportType
vel_fixmode,
103
AltMode
alt=
ALT_NOCHANGE
,
104
PPSMode
pps=
PPS_NOCHANGE
,
105
GPSTimeMode
time=
TME_NOCHANGE
,
106
bool
block=
false
);
107
108
HardwareSerial *
getSerial
();
109
const
PosFix
&
getPositionFix
()
const
;
110
const
VelFix
&
getVelocityFix
()
const
;
111
const
GPSTime
&
getGPSTime
()
const
;
112
const
GPSStatus
&
getStatus
()
const
;
113
114
bool
addPacketProcessor
(
GPSPacketProcessor
*pcs);
115
void
removePacketProcessor
(
GPSPacketProcessor
*pcs);
116
117
private
:
118
119
ReportType
implProcessOnePacket(
bool
block,
ReportType
haltAt);
120
121
bool
processReport(
ReportType
type);
122
123
bool
process_p_LLA_32();
124
bool
process_p_LLA_64();
125
bool
process_p_XYZ_32();
126
bool
process_p_XYZ_64();
127
bool
process_v_XYZ();
128
bool
process_v_ENU();
129
bool
process_GPSTime();
130
bool
process_health();
131
bool
process_addl_status();
132
bool
process_sbas_status();
133
134
// todo: fix this busy wait.
135
inline
void
blockForData() {
while
(m_serial->available() <= 0) {} }
136
bool
flushToNextPacket(
bool
block=
true
);
137
bool
endReport();
138
139
HardwareSerial *m_serial;
140
PosFix
m_pfix;
141
VelFix
m_vfix;
142
GPSTime
m_time;
143
GPSStatus
m_status;
144
GPSPacketProcessor
*m_listeners[
MAX_PKT_PROCESSORS
];
145
uint8_t m_n_listeners;
146
};
147
149
150
#endif
/* COPERNICUS_H */
151
Generated on Mon Oct 14 2013 01:54:29 for Copernicus by
1.8.3.1