Copernicus  1.0
An Arduino module for the Trimble Copernicus GPS receiver
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Groups
Public Member Functions | List of all members
CopernicusGPS Class Reference

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 PosFixgetPositionFix () const
 
const VelFixgetVelocityFix () const
 
const GPSTimegetGPSTime () const
 
const GPSStatusgetStatus () const
 
bool addPacketProcessor (GPSPacketProcessor *pcs)
 
void removePacketProcessor (GPSPacketProcessor *pcs)
 

Detailed Description

Class for communication with Trimble Copernicus GPS chip.

Constructor & Destructor Documentation

CopernicusGPS::CopernicusGPS ( int  serial_num = 0)

Construct a new CopernicusGPS object.

Parameters
serial_numArduino serial stream to monitor. 0 is Serial, 1 is Serial1, etc.

Member Function Documentation

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.

Parameters
pcsProcessor to add.
Returns
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.

Parameters
cmdCommand 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
     }
 }
Parameters
blockIf true, will always wait for a complete packet to arrive.
Returns
The report ID of the processed packet, or 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).

Parameters
dstDestination buffer.
nNumber of decoded bytes to read.
Returns
Number of bytes actually written to dst.
void CopernicusGPS::removePacketProcessor ( GPSPacketProcessor pcs)

Cease to notify the given GPSPacketProcessor of incoming TSIP packets.

Parameters
pcsProcessor 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.

Parameters
pos_fixmodeNew position fix format. Any of the RPT_FIX_POS_* constants, or RPT_NONE.
vel_fixmodeNew velocity fix format. Any of the RPT_FIX_VEL_* constants, or RPT_NONE.
altNew altitude format.
ppsNew PPS setting.
timeNew GPS time format.
blockWhether to wait for a confirmation from the receiver that the settings have taken effect.
Returns
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.

Parameters
typeType 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().

Parameters
bytesData bytes to encode and send.
nNumber of bytes to encode.

The documentation for this class was generated from the following files: