Main Page   Interface   Data Structures   File List   Data Fields   Globals  

GPS.c File Reference

Balloon Flight GPS utilities, Implementation. More...

#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include "BBC/GPS.h"

Defines

#define SL_ERROR   -1
 Error on a serial line operation.

#define PREAMBLE   (( '@' << 24) | ('@' << 16) | ('E' << 8) | ('q' << 0))
 Internal constant for @Eq.

#define POSTAMBLE   (('\r' << 8) | ('\n' << 0))
 Internal constant for CR LF.


Functions

int set_baud_rate (int fd, int rate)
 Sets the BAUD rate. More...

int set_raw_mode (int fd)
 Sets the serial line into raw mode. More...

int flush_stream (int fd)
 Flushs the serial line. More...

unsigned int cvt2 (const unsigned char *beg)
 Converts 2 digit string to a number, base 10. More...

GPS_status GPS_verify (const unsigned char buf[GPS_K_PM_MBF_SIZE])
 Performs rudimentary checks on the GPS record. More...

int GPS_checksum_verify (const unsigned char buf[GPS_K_PM_MBF_SIZE])
 Verifies the checksum for the GPS record. More...

int GPS_init (int fd)
 Initializes the GPS device. More...

int GPS_open (const char *dev_name)
 Opens a file descriptor to the GPS device. More...

int GPS_read (int fd, unsigned char buf[GPS_K_PM_MBF_SIZE])
 Reads the GPS message. More...

int GPS_rate_set (int fd, int rate)
 Sets the update frequency. More...

time_t GPS_utc_get (const unsigned char buf[GPS_K_PM_MBF_SIZE])
 Converts a position message in Motorola Binary Format to a UTC time. The precision is seconds. More...


Detailed Description

Balloon Flight GPS utilities, Implementation.

Author:
JJRussell - russell@slac.stanford.edu

Function Documentation

unsigned int cvt2 const unsigned char *    beg [inline, static]
 

Converts 2 digit string to a number, base 10.

Parameters:
beg  Pointer to the first character to be converted.
Returns:
The UTC time.

int flush_stream int    fd [inline, static]
 

Flushs the serial line.

Parameters:
fd  The file descriptor of the serial line
Returns:
Status

int GPS_checksum_verify const unsigned char    buf[GPS_K_PM_MBF_SIZE]
 

Verifies the checksum for the GPS record.

Parameters:
buf  The buffer containing the GPS record to verify.
Returns:
Status, 0 if else non-zero

int GPS_init int    fd
 

Initializes the GPS device.

Parameters:
fd  A previously opened file descriptor to the GPS device
Returns:
Status, 0 if okay, -1 if error.

int GPS_open const char *    dev_name
 

Opens a file descriptor to the GPS device.

Parameters:
dev_name  The name of the GPS device. If given as NULL, defaults to "/tyCo/1".
Returns:
The file descriptor.
Separating the open from the initialization allows for some testing.

int GPS_rate_set int    fd,
int    rate
 

Sets the update frequency.

Parameters:
fd  A previously opened file descriptor to the GPS device
rate  The update rate, in seconds (between 0-255).
Returns:
Status, 0 if okay, -1 if error.

int GPS_read int    fd,
unsigned char    buf[GPS_K_PM_MBF_SIZE]
 

Reads the GPS message.

Parameters:
fd  The file descriptor to read.
buf  The buffer to receive the ASCII message.
Returns:
>= 0 The number of attempts (after the initial attempt) until successfully read 96 bytes ending in CR/LF. -1 if have an IO error. -2 an insufficient number of bytes where read before encountering LF. The length of
This routine should only be used for the most rudimentary testing. Reading the GPS message correctly requires some method of synchronizing to the message arrival. This synchronization is outside the scope of these routines. Once one is synchronized, all that is needed is a simple read (fd, buf, 96) call.

time_t GPS_utc_get const unsigned char    buf[GPS_K_PM_MBF_SIZE]
 

Converts a position message in Motorola Binary Format to a UTC time. The precision is seconds.

Parameters:
buf  The GPS time/position message.
Returns:
The UTC time in seconds after 1970

GPS_status GPS_verify const unsigned char    buf[GPS_K_PM_MBF_SIZE]
 

Performs rudimentary checks on the GPS record.

Parameters:
buf  The buffer containing the GPS record to verify.
Return values:
GPS_C_STATUS_OKAY 
GPS_C_STATUS_ERR_PREAMBLE 
GPS_C_STATUS_ERR_POSTAMBLE 
GPS_C_STATUS_ERR_CHECKSUM 

int set_baud_rate int    fd,
int    rate
[inline, static]
 

Sets the BAUD rate.

Parameters:
fd  The file descriptor of the serial line
rate  The baud rate to set.
Returns:
Status

int set_raw_mode int    fd [inline, static]
 

Sets the serial line into raw mode.

Parameters:
fd  The file descriptor of the serial line
Returns:
Status


Generated on Fri Mar 1 16:55:24 2002 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001