C027 の mbes os 5 での動作を確認しました。 I confirmed the operation at mbes os 5 of C 027.

Fork of C027_Support by u-blox

Embed: (wiki syntax)

« Back to documentation index

GPSI2C Class Reference

gps class which uses a i2c as physical interface. More...

#include <GPS.h>

Inherits GPSParser.

Public Types

enum  { WAIT = -1, NOT_FOUND = 0 }

Public Member Functions

 GPSI2C (PinName sda GPS_IF(=GPSSDA,=D14), PinName scl GPS_IF(=GPSSCL,=D15), unsigned char i2cAdr GPS_IF(=GPSADR,=(66<< 1)), int rxSize=256)
 Constructor.
virtual ~GPSI2C (void)
 Destructor.
virtual bool init (PinName pn=GPS_IF(GPSINT, NC))
 helper function to probe the i2c device
virtual int getMessage (char *buf, int len)
 Get a line from the physical interface.
virtual int send (const char *buf, int len)
 send a buffer
virtual int sendNmea (const char *buf, int len)
 send a NMEA message, this function just takes the payload and calculates and adds checksum.
virtual int sendUbx (unsigned char cls, unsigned char id, const void *buf=NULL, int len=0)
 send a UBX message, this function just takes the payload and calculates and adds checksum.
void powerOff (void)
 Power off the gps, it can be again woken up by an edge on the serial port on the external interrupt pin.

Static Public Member Functions

static const char * findNmeaItemPos (int ix, const char *start, const char *end)
 get the first character of a NMEA field
static bool getNmeaItem (int ix, char *buf, int len, double &val)
 extract a double value from a buffer containing a NMEA message
static bool getNmeaItem (int ix, char *buf, int len, int &val, int base)
 extract a interger value from a buffer containing a NMEA message
static bool getNmeaItem (int ix, char *buf, int len, char &val)
 extract a char value from a buffer containing a NMEA message
static bool getNmeaAngle (int ix, char *buf, int len, double &val)
 extract a latitude/longitude value from a buffer containing a NMEA message

Protected Member Functions

bool writeable (void)
 check if the port is writeable (like SerialPipe)
bool putc (int c)
 Write a character (like SerialPipe)
virtual int _send (const void *buf, int len)
 Write bytes to the physical interface.
int _get (char *buf, int len)
 read bytes from the physical interface.

Static Protected Member Functions

static int _getMessage (Pipe< char > *pipe, char *buf, int len)
 Get a line from the physical interface.
static int _parseNmea (Pipe< char > *pipe, int len)
 Check if the current offset of the pipe contains a NMEA message.
static int _parseUbx (Pipe< char > *pipe, int len)
 Check if the current offset of the pipe contains a UBX message.

Protected Attributes

Pipe< char > _pipe
 the rx pipe
unsigned char _i2cAdr
 the i2c address

Static Protected Attributes

static const char REGLEN = 0xFD
 the length i2c register address
static const char REGSTREAM = 0xFF
 the stream i2c register address
static const char toHex [16] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' }
 num to hex conversion

Detailed Description

gps class which uses a i2c as physical interface.

Definition at line 208 of file GPS.h.


Member Enumeration Documentation

anonymous enum [inherited]
Enumerator:
WAIT 

wait for more incoming data (the start of a message was found, or no data available)

NOT_FOUND 

a parser concluded the the current offset of the pipe doe not contain a valid message

Definition at line 22 of file GPS.h.


Constructor & Destructor Documentation

GPSI2C ( PinName sda   GPS_IF=GPSSDA,=D14,
PinName scl   GPS_IF=GPSSCL,=D15,
unsigned char i2cAdr   GPS_IF=GPSADR,=(66<< 1),
int  rxSize = 256 
)

Constructor.

Parameters:
sdais the I2C SDA pin (between CPU and GPS)
sclis the I2C SCL pin (CPU to GPS)
adrthe I2C address of the GPS set to (66<<1)
rxSizethe size of the serial rx buffer
~GPSI2C ( void   ) [virtual]

Destructor.

Definition at line 301 of file GPS.cpp.


Member Function Documentation

int _get ( char *  buf,
int  len 
) [protected]

read bytes from the physical interface.

Parameters:
bufthe buffer to read into
lensize of the read buffer
Returns:
bytes read

Definition at line 363 of file GPS.cpp.

int _getMessage ( Pipe< char > *  pipe,
char *  buf,
int  len 
) [static, protected, inherited]

Get a line from the physical interface.

Parameters:
pipethe receiveing pipe to parse messages
bufthe buffer to store it
lensize of the buffer
Returns:
type and length if something was found, WAIT if not enough data is available NOT_FOUND if nothing was found

Definition at line 15 of file GPS.cpp.

int _parseNmea ( Pipe< char > *  pipe,
int  len 
) [static, protected, inherited]

Check if the current offset of the pipe contains a NMEA message.

Parameters:
pipethe receiveing pipe to parse messages
lennumer of bytes to parse at maximum
Returns:
length if something was found (including the NMEA frame) WAIT if not enough data is available NOT_FOUND if nothing was found

Definition at line 53 of file GPS.cpp.

int _parseUbx ( Pipe< char > *  pipe,
int  len 
) [static, protected, inherited]

Check if the current offset of the pipe contains a UBX message.

Parameters:
pipethe receiveing pipe to parse messages
lennumer of bytes to parse at maximum
Returns:
length if something was found (including the UBX frame) WAIT if not enough data is available NOT_FOUND if nothing was found

Definition at line 82 of file GPS.cpp.

int _send ( const void *  buf,
int  len 
) [protected, virtual]

Write bytes to the physical interface.

Parameters:
bufthe buffer to write
lensize of the buffer to write
Returns:
bytes written

Implements GPSParser.

Definition at line 384 of file GPS.cpp.

const char * findNmeaItemPos ( int  ix,
const char *  start,
const char *  end 
) [static, inherited]

get the first character of a NMEA field

Parameters:
ixthe index of the field to find
startthe start of the buffer
endthe end of the buffer
Returns:
the pointer to the first character of the field.

Definition at line 158 of file GPS.cpp.

int getMessage ( char *  buf,
int  len 
) [virtual]

Get a line from the physical interface.

Parameters:
bufthe buffer to store it
lensize of the buffer
Returns:
type and length if something was found, WAIT if not enough data is available NOT_FOUND if nothing was found

Implements GPSParser.

Definition at line 321 of file GPS.cpp.

bool getNmeaAngle ( int  ix,
char *  buf,
int  len,
double &  val 
) [static, inherited]

extract a latitude/longitude value from a buffer containing a NMEA message

Parameters:
ixthe index of the field to extract (will extract ix and ix + 1)
bufthe NMEA message
lenthe size of the NMEA message
valthe extracted latitude or longitude
Returns:
true if successful, false otherwise

Definition at line 217 of file GPS.cpp.

bool getNmeaItem ( int  ix,
char *  buf,
int  len,
char &  val 
) [static, inherited]

extract a char value from a buffer containing a NMEA message

Parameters:
ixthe index of the field to extract
bufthe NMEA message
lenthe size of the NMEA message
valthe extracted value
Returns:
true if successful, false otherwise

Definition at line 197 of file GPS.cpp.

bool getNmeaItem ( int  ix,
char *  buf,
int  len,
int &  val,
int  base 
) [static, inherited]

extract a interger value from a buffer containing a NMEA message

Parameters:
ixthe index of the field to extract
bufthe NMEA message
lenthe size of the NMEA message
valthe extracted value
basethe numeric base to be used (e.g. 8, 10 or 16)
Returns:
true if successful, false otherwise

Definition at line 186 of file GPS.cpp.

bool getNmeaItem ( int  ix,
char *  buf,
int  len,
double &  val 
) [static, inherited]

extract a double value from a buffer containing a NMEA message

Parameters:
ixthe index of the field to extract
bufthe NMEA message
lenthe size of the NMEA message
valthe extracted value
Returns:
true if successful, false otherwise

Definition at line 174 of file GPS.cpp.

bool init ( PinName  pn = GPS_IF( GPSINT, NC ) ) [virtual]

helper function to probe the i2c device

Returns:
true if successfully detected the gps.

Implements GPSParser.

Definition at line 310 of file GPS.cpp.

void powerOff ( void   ) [inherited]

Power off the gps, it can be again woken up by an edge on the serial port on the external interrupt pin.

Definition at line 8 of file GPS.cpp.

bool putc ( int  c ) [protected]

Write a character (like SerialPipe)

Parameters:
cthe character to write
Returns:
true if succesffully written

Definition at line 274 of file GPS.h.

int send ( const char *  buf,
int  len 
) [virtual]

send a buffer

Parameters:
bufthe buffer to write
lensize of the buffer to write
Returns:
bytes written

Reimplemented from GPSParser.

Definition at line 333 of file GPS.cpp.

int sendNmea ( const char *  buf,
int  len 
) [virtual]

send a NMEA message, this function just takes the payload and calculates and adds checksum.

($ and *XX
will be added)

Parameters:
bufthe message payload to write
lensize of the message payload to write
Returns:
total bytes written

Reimplemented from GPSParser.

Definition at line 345 of file GPS.cpp.

int sendUbx ( unsigned char  cls,
unsigned char  id,
const void *  buf = NULL,
int  len = 0 
) [virtual]

send a UBX message, this function just takes the payload and calculates and adds checksum.

Parameters:
clsthe UBX class id
idthe UBX message id
bufthe message payload to write
lensize of the message payload to write
Returns:
total bytes written

Reimplemented from GPSParser.

Definition at line 354 of file GPS.cpp.

bool writeable ( void   ) [protected]

check if the port is writeable (like SerialPipe)

Returns:
true if writeable

Definition at line 268 of file GPS.h.


Field Documentation

unsigned char _i2cAdr [protected]

the i2c address

Definition at line 291 of file GPS.h.

Pipe<char> _pipe [protected]

the rx pipe

Definition at line 290 of file GPS.h.

const char REGLEN = 0xFD [static, protected]

the length i2c register address

Definition at line 292 of file GPS.h.

const char REGSTREAM = 0xFF [static, protected]

the stream i2c register address

Definition at line 293 of file GPS.h.

const char toHex = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' } [static, protected, inherited]

num to hex conversion

Definition at line 158 of file GPS.h.