Copernicus
1.0
An Arduino module for the Trimble Copernicus GPS receiver
|
Class for communication with Trimble Copernicus GPS chip. More...
#include <copernicus.h>
Public Member Functions | |
CopernicusGPS (int serial=0) | |
ReportType | processOnePacket (bool block=false) |
void | waitForPacket (ReportType type) |
void | beginCommand (CommandID cmd) |
void | writeDataBytes (const uint8_t *bytes, int n) |
int | readDataBytes (uint8_t *dst, int n) |
void | endCommand () |
bool | setFixMode (ReportType pos_fixmode, ReportType vel_fixmode, AltMode alt=ALT_NOCHANGE, PPSMode pps=PPS_NOCHANGE, GPSTimeMode time=TME_NOCHANGE, bool block=false) |
HardwareSerial * | getSerial () |
const PosFix & | getPositionFix () const |
const VelFix & | getVelocityFix () const |
const GPSTime & | getGPSTime () const |
const GPSStatus & | getStatus () const |
bool | addPacketProcessor (GPSPacketProcessor *pcs) |
void | removePacketProcessor (GPSPacketProcessor *pcs) |
Class for communication with Trimble Copernicus GPS chip.
CopernicusGPS::CopernicusGPS | ( | int | serial_num = 0 | ) |
Construct a new CopernicusGPS
object.
serial_num | Arduino serial stream to monitor. 0 is Serial , 1 is Serial1 , etc. |
bool CopernicusGPS::addPacketProcessor | ( | GPSPacketProcessor * | pcs | ) |
Add a GPSPacketProcessor
to be notified of incoming TSIP packets. At most MAX_PKT_PROCESSORS
(8) are supported at a time.
pcs | Processor to add. |
false
if there was not enough space to add the processor, true
otherwise. void CopernicusGPS::beginCommand | ( | CommandID | cmd | ) |
Begin a TSIP command by sending the header bytes for the given command type.
cmd | Command to begin. |
void CopernicusGPS::endCommand | ( | ) |
End a command by sending the end-of-transmission byte sequence.
const GPSTime & CopernicusGPS::getGPSTime | ( | ) | const |
Get the most recent GPS time report. For accurate current time, this datum must be correlated with a PPS pulse signal.
const PosFix & CopernicusGPS::getPositionFix | ( | ) | const |
Get the most current position fix.
HardwareSerial * CopernicusGPS::getSerial | ( | ) |
Get the monitored Serial IO object.
const GPSStatus & CopernicusGPS::getStatus | ( | ) | const |
Get the status and health of the reciever. If the unit has a GPS lock, getStatus().health
will equal HLTH_DOING_FIXES
.
const VelFix & CopernicusGPS::getVelocityFix | ( | ) | const |
Get the most current velocity fix.
ReportType CopernicusGPS::processOnePacket | ( | bool | block = false | ) |
Process one TSIP packet from the stream, returning the ID of the packet processed. If block
is false
, this function will return RPT_NONE
if no packet data was available. Otherwise, a valid packet ID or RPT_ERROR
will be returned.
Must be called regularly or in response to serial events. Example usage:
// flush packets in a tight loop: while (gps.processOnePacket(false) != RPT_NONE) {}
Event handling:
ReportType evt; while ((evt = gps.processOnePacket(false)) != RPT_NONE) { switch (evt) { // respond to updates } }
block | If true , will always wait for a complete packet to arrive. |
RPT_NONE
if block
is false
and no data was available. int CopernicusGPS::readDataBytes | ( | uint8_t * | dst, |
int | n | ||
) |
Read data bytes from a TSIP report packet, unpacking any escape sequences in the process, placing n
decoded bytes into dst
. Blocks until n
bytes are decoded, or the end of the packet is reached (in which case the two end-of-packet bytes will be consumed).
dst | Destination buffer. |
n | Number of decoded bytes to read. |
dst
. void CopernicusGPS::removePacketProcessor | ( | GPSPacketProcessor * | pcs | ) |
Cease to notify the given GPSPacketProcessor
of incoming TSIP packets.
pcs | Processor to remove. |
bool CopernicusGPS::setFixMode | ( | ReportType | pos_fixmode, |
ReportType | vel_fixmode, | ||
AltMode | alt = ALT_NOCHANGE , |
||
PPSMode | pps = PPS_NOCHANGE , |
||
GPSTimeMode | time = TME_NOCHANGE , |
||
bool | block = false |
||
) |
Set the format of position, velocity, and altitude fixes. PPS settings and GPS time format may also be set with this command.
To leave a fix mode unchanged, pass RPT_NONE
. Other mode settings have NOCHANGE
constants which will preserve the current settings.
pos_fixmode | New position fix format. Any of the RPT_FIX_POS_* constants, or RPT_NONE . |
vel_fixmode | New velocity fix format. Any of the RPT_FIX_VEL_* constants, or RPT_NONE . |
alt | New altitude format. |
pps | New PPS setting. |
time | New GPS time format. |
block | Whether to wait for a confirmation from the receiver that the settings have taken effect. |
true
if the settings were change successfully, false
if an I/O problem occurred. void CopernicusGPS::waitForPacket | ( | ReportType | type | ) |
Process packets/input until the header of a packet with type type
is encountered, at which point the stream will be left for the caller to process. The caller should fully consume the packet, including the end-of-packet bytes.
type | Type of packet to wait for. |
void CopernicusGPS::writeDataBytes | ( | const uint8_t * | bytes, |
int | n | ||
) |
Encode n
data bytes as part of a TSIP command packet and send them to the gps module. Must be called only if a command has been opened with a call to beginCommand()
, and may be called multiple times before a call to endCommand()
.
bytes | Data bytes to encode and send. |
n | Number of bytes to encode. |