\hypertarget{GPS_8h}{
\section{GPS.h File Reference}
\label{GPS_8h}\index{GPS.h@{GPS.h}}
}
Balloon Flight GPS utilities, Interface. 


{\tt \#include $<$time.h$>$}\par
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__GPS__irep}{\_\-GPS\_\-irep}
\begin{CompactList}\small\item\em An integer binary representation of the GPS data.\item\end{CompactList}\item 
struct \hyperlink{struct__GPS__latitude}{\_\-GPS\_\-latitude}
\begin{CompactList}\small\item\em Holds a latitude reading.\item\end{CompactList}\item 
struct \hyperlink{struct__GPS__longitude}{\_\-GPS\_\-longitude}
\begin{CompactList}\small\item\em Holds a longitude reading.\item\end{CompactList}\item 
struct \hyperlink{struct__GPS__pm__mbf}{\_\-GPS\_\-pm\_\-mbf}
\begin{CompactList}\small\item\em Symbolic layout of a GPS Position Message in Motorola Binary Format.\item\end{CompactList}\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\hypertarget{GPS_8h_a0}{
\index{GPS_K_PM_MBF_SIZE@{GPS\_\-K\_\-PM\_\-MBF\_\-SIZE}!GPS.h@{GPS.h}}\index{GPS.h@{GPS.h}!GPS_K_PM_MBF_SIZE@{GPS\_\-K\_\-PM\_\-MBF\_\-SIZE}}
\#define \hyperlink{GPS_8h_a0}{GPS\_\-K\_\-PM\_\-MBF\_\-SIZE}\ (sizeof (\hyperlink{GPS_8h_a2}{GPS\_\-pm\_\-mbf}))}
\label{GPS_8h_a0}

\begin{CompactList}\small\item\em The size, in bytes of a GPS record.\item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{GPS_8h_a1}{
\index{GPS_status@{GPS\_\-status}!GPS.h@{GPS.h}}\index{GPS.h@{GPS.h}!GPS_status@{GPS\_\-status}}
typedef enum \hyperlink{GPS_8h_a27}{\_\-GPS\_\-status} \hyperlink{GPS_8h_a1}{GPS\_\-status}}
\label{GPS_8h_a1}

\begin{CompactList}\small\item\em Typedef for the enum \_\-GPS\_\-status.\item\end{CompactList}\item 
\hypertarget{GPS_8h_a2}{
\index{GPS_pm_mbf@{GPS\_\-pm\_\-mbf}!GPS.h@{GPS.h}}\index{GPS.h@{GPS.h}!GPS_pm_mbf@{GPS\_\-pm\_\-mbf}}
typedef \hyperlink{struct__GPS__pm__mbf}{\_\-GPS\_\-pm\_\-mbf} \hyperlink{GPS_8h_a2}{GPS\_\-pm\_\-mbf}}
\label{GPS_8h_a2}

\begin{CompactList}\small\item\em Typedef for the struct \hyperlink{struct__GPS__pm__mbf}{\_\-GPS\_\-pm\_\-mbf}.\item\end{CompactList}\item 
typedef \hyperlink{struct__GPS__latitude}{\_\-GPS\_\-latitude} \hyperlink{GPS_8h_a3}{GPS\_\-latitude}
\begin{CompactList}\small\item\em Typedef for struct GPS\_\-latitude.\item\end{CompactList}\item 
typedef \hyperlink{struct__GPS__longitude}{\_\-GPS\_\-longitude} \hyperlink{GPS_8h_a4}{GPS\_\-longitude}
\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__GPS__longitude}{\_\-GPS\_\-longitude}.\item\end{CompactList}\item 
typedef enum \hyperlink{GPS_8h_a28}{\_\-GPS\_\-fix\_\-mode} \hyperlink{GPS_8h_a5}{GPS\_\-fix\_\-mode}
\begin{CompactList}\small\item\em Typedef for enum \_\-GPS\_\-fix\_\-mode.\item\end{CompactList}\item 
typedef enum \hyperlink{GPS_8h_a29}{\_\-GPS\_\-fix\_\-type} \hyperlink{GPS_8h_a6}{GPS\_\-fix\_\-type}
\begin{CompactList}\small\item\em Typedef for enum \_\-GPS\_\-fix\_\-type.\item\end{CompactList}\item 
typedef \hyperlink{struct__GPS__irep}{\_\-GPS\_\-irep} \hyperlink{GPS_8h_a7}{GPS\_\-irep}
\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__GPS__irep}{\_\-GPS\_\-irep}.\item\end{CompactList}\end{CompactItemize}
\subsection*{Enumerations}
\begin{CompactItemize}
\item 
enum \hyperlink{GPS_8h_a27}{\_\-GPS\_\-status} \{ \hyperlink{GPS_8h_a27a8}{GPS\_\-C\_\-STATUS\_\-ERR\_\-CHECKSUM} =  -5, 
\hyperlink{GPS_8h_a27a9}{GPS\_\-C\_\-STATUS\_\-ERR\_\-POSTAMBLE} =  -4, 
\hyperlink{GPS_8h_a27a10}{GPS\_\-C\_\-STATUS\_\-ERR\_\-PREAMBLE} =  -3, 
\hyperlink{GPS_8h_a27a11}{GPS\_\-C\_\-STATUS\_\-ERR\_\-TOO\_\-SHORT} =  -2, 
\hyperlink{GPS_8h_a27a12}{GPS\_\-C\_\-STATUS\_\-ERR\_\-IO} =  -1, 
\hyperlink{GPS_8h_a27a13}{GPS\_\-C\_\-STATUS\_\-OKAY} =   0
 \}
\begin{CompactList}\small\item\em The status codes returned by the GPS facility.\item\end{CompactList}\item 
enum \hyperlink{GPS_8h_a28}{\_\-GPS\_\-fix\_\-mode} \{ \hyperlink{GPS_8h_a28a14}{GPS\_\-K\_\-FIX\_\-MODE\_\-AUTONOMOUS} =  0, 
\hyperlink{GPS_8h_a28a15}{GPS\_\-K\_\-FIX\_\-TYPE\_\-DIFFERENTIAL} =  1
 \}
\begin{CompactList}\small\item\em The fix modes.\item\end{CompactList}\item 
enum \hyperlink{GPS_8h_a29}{\_\-GPS\_\-fix\_\-type} \{ \hyperlink{GPS_8h_a29a16}{GPS\_\-K\_\-FIX\_\-TYPE\_\-NONE} =  0, 
\hyperlink{GPS_8h_a29a17}{GPS\_\-K\_\-FIX\_\-TYPE\_\-1D} =  1, 
\hyperlink{GPS_8h_a29a18}{GPS\_\-K\_\-FIX\_\-TYPE\_\-2D} =  2, 
\hyperlink{GPS_8h_a29a19}{GPS\_\-K\_\-FIX\_\-TYPE\_\-PROPOGATE} =  3
 \}
\begin{CompactList}\small\item\em The fix types.\item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
int \hyperlink{GPS_8h_a20}{GPS\_\-open} (const char $\ast$dev\_\-name)
\begin{CompactList}\small\item\em Opens a {\em file} descriptor to the GPS device.\item\end{CompactList}\item 
int \hyperlink{GPS_8h_a21}{GPS\_\-init} (int fd)
\begin{CompactList}\small\item\em Initializes the GPS device.\item\end{CompactList}\item 
int \hyperlink{GPS_8h_a22}{GPS\_\-rate\_\-set} (int fd, int rate)
\begin{CompactList}\small\item\em Sets the update frequency.\item\end{CompactList}\item 
int \hyperlink{GPS_8h_a23}{GPS\_\-read} (int fd, unsigned char buf\mbox{[}GPS\_\-K\_\-PM\_\-MBF\_\-SIZE\mbox{]})
\begin{CompactList}\small\item\em Reads the GPS message.\item\end{CompactList}\item 
\hyperlink{GPS_8h_a1}{GPS\_\-status} \hyperlink{GPS_8h_a24}{GPS\_\-verify} (const unsigned char buf\mbox{[}GPS\_\-K\_\-PM\_\-MBF\_\-SIZE\mbox{]})
\begin{CompactList}\small\item\em Performs rudimentary checks on the GPS record.\item\end{CompactList}\item 
int \hyperlink{GPS_8h_a25}{GPS\_\-checksum\_\-verify} (const unsigned char buf\mbox{[}GPS\_\-K\_\-PM\_\-MBF\_\-SIZE\mbox{]})
\begin{CompactList}\small\item\em Verifies the checksum for the GPS record.\item\end{CompactList}\item 
time\_\-t \hyperlink{GPS_8h_a26}{GPS\_\-utc\_\-get} (const unsigned char buf\mbox{[}GPS\_\-K\_\-PM\_\-MBF\_\-SIZE\mbox{]})
\begin{CompactList}\small\item\em Converts a position message in Motorola Binary Format to a UTC time. The precision is seconds.\item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Balloon Flight GPS utilities, Interface.



\begin{Desc}
\item[Author: ]\par
JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}


\subsection{Typedef Documentation}
\hypertarget{GPS_8h_a5}{
\index{GPS.h@{GPS.h}!GPS_fix_mode@{GPS\_\-fix\_\-mode}}
\index{GPS_fix_mode@{GPS\_\-fix\_\-mode}!GPS.h@{GPS.h}}
\subsubsection[GPS\_\-fix\_\-mode]{\setlength{\rightskip}{0pt plus 5cm}GPS\_\-fix\_\-mode}}
\label{GPS_8h_a5}


Typedef for enum \_\-GPS\_\-fix\_\-mode.



 These enumerate the various fix modes. \hypertarget{GPS_8h_a6}{
\index{GPS.h@{GPS.h}!GPS_fix_type@{GPS\_\-fix\_\-type}}
\index{GPS_fix_type@{GPS\_\-fix\_\-type}!GPS.h@{GPS.h}}
\subsubsection[GPS\_\-fix\_\-type]{\setlength{\rightskip}{0pt plus 5cm}GPS\_\-fix\_\-type}}
\label{GPS_8h_a6}


Typedef for enum \_\-GPS\_\-fix\_\-type.



 These enumerate the various fix types. \hypertarget{GPS_8h_a7}{
\index{GPS.h@{GPS.h}!GPS_irep@{GPS\_\-irep}}
\index{GPS_irep@{GPS\_\-irep}!GPS.h@{GPS.h}}
\subsubsection[GPS\_\-irep]{\setlength{\rightskip}{0pt plus 5cm}GPS\_\-irep}}
\label{GPS_8h_a7}


Typedef for struct \hyperlink{struct__GPS__irep}{\_\-GPS\_\-irep}.



 This structue is designed to hold all the information present in a GPS ASCII record without without losing any accuracy and without using any floating point representations. Care is taken to 4-byte align the quantities. \hypertarget{GPS_8h_a3}{
\index{GPS.h@{GPS.h}!GPS_latitude@{GPS\_\-latitude}}
\index{GPS_latitude@{GPS\_\-latitude}!GPS.h@{GPS.h}}
\subsubsection[GPS\_\-latitude]{\setlength{\rightskip}{0pt plus 5cm}GPS\_\-latitude}}
\label{GPS_8h_a3}


Typedef for struct GPS\_\-latitude.



 This structure is designed to hold all the information present in a GPS latitude reading without using any accuracy (for instance by translating minutes to decimal fractions of a degree) or using a floating point representation. \hypertarget{GPS_8h_a4}{
\index{GPS.h@{GPS.h}!GPS_longitude@{GPS\_\-longitude}}
\index{GPS_longitude@{GPS\_\-longitude}!GPS.h@{GPS.h}}
\subsubsection[GPS\_\-longitude]{\setlength{\rightskip}{0pt plus 5cm}GPS\_\-longitude}}
\label{GPS_8h_a4}


Typedef for struct \hyperlink{struct__GPS__longitude}{\_\-GPS\_\-longitude}.



 This structure is designed to hold all the information present in a GPS longitude reading without losing any accuracy (for instance by translating minutes to decimal fractions of a degree) or using a floating point representation. 

\subsection{Enumeration Type Documentation}
\hypertarget{GPS_8h_a28}{
\index{GPS.h@{GPS.h}!_GPS_fix_mode@{\_\-GPS\_\-fix\_\-mode}}
\index{_GPS_fix_mode@{\_\-GPS\_\-fix\_\-mode}!GPS.h@{GPS.h}}
\subsubsection[\_\-GPS\_\-fix\_\-mode]{\setlength{\rightskip}{0pt plus 5cm}enum \_\-GPS\_\-fix\_\-mode}}
\label{GPS_8h_a28}


The fix modes.

\begin{Desc}
\item[Enumeration values:]\par
\begin{description}
\index{GPS_K_FIX_MODE_AUTONOMOUS@{GPS\_\-K\_\-FIX\_\-MODE\_\-AUTONOMOUS}!GPS.h@{GPS.h}}\index{GPS.h@{GPS.h}!GPS_K_FIX_MODE_AUTONOMOUS@{GPS\_\-K\_\-FIX\_\-MODE\_\-AUTONOMOUS}}\item[{\em 
\hypertarget{GPS_8h_a28a14}{
{\em GPS\_\-K\_\-FIX\_\-MODE\_\-AUTONOMOUS}}
\label{GPS_8h_a28a14}
}]GPS fix mode = Autonomous \index{GPS_K_FIX_TYPE_DIFFERENTIAL@{GPS\_\-K\_\-FIX\_\-TYPE\_\-DIFFERENTIAL}!GPS.h@{GPS.h}}\index{GPS.h@{GPS.h}!GPS_K_FIX_TYPE_DIFFERENTIAL@{GPS\_\-K\_\-FIX\_\-TYPE\_\-DIFFERENTIAL}}\item[{\em 
\hypertarget{GPS_8h_a28a15}{
{\em GPS\_\-K\_\-FIX\_\-TYPE\_\-DIFFERENTIAL}}
\label{GPS_8h_a28a15}
}]GPS fix mode = Differential \end{description}
\end{Desc}

\hypertarget{GPS_8h_a29}{
\index{GPS.h@{GPS.h}!_GPS_fix_type@{\_\-GPS\_\-fix\_\-type}}
\index{_GPS_fix_type@{\_\-GPS\_\-fix\_\-type}!GPS.h@{GPS.h}}
\subsubsection[\_\-GPS\_\-fix\_\-type]{\setlength{\rightskip}{0pt plus 5cm}enum \_\-GPS\_\-fix\_\-type}}
\label{GPS_8h_a29}


The fix types.

\begin{Desc}
\item[Enumeration values:]\par
\begin{description}
\index{GPS_K_FIX_TYPE_NONE@{GPS\_\-K\_\-FIX\_\-TYPE\_\-NONE}!GPS.h@{GPS.h}}\index{GPS.h@{GPS.h}!GPS_K_FIX_TYPE_NONE@{GPS\_\-K\_\-FIX\_\-TYPE\_\-NONE}}\item[{\em 
\hypertarget{GPS_8h_a29a16}{
{\em GPS\_\-K\_\-FIX\_\-TYPE\_\-NONE}}
\label{GPS_8h_a29a16}
}]GPS fix type = NONE \index{GPS_K_FIX_TYPE_1D@{GPS\_\-K\_\-FIX\_\-TYPE\_\-1D}!GPS.h@{GPS.h}}\index{GPS.h@{GPS.h}!GPS_K_FIX_TYPE_1D@{GPS\_\-K\_\-FIX\_\-TYPE\_\-1D}}\item[{\em 
\hypertarget{GPS_8h_a29a17}{
{\em GPS\_\-K\_\-FIX\_\-TYPE\_\-1D}}
\label{GPS_8h_a29a17}
}]GPS fix type = 1D \index{GPS_K_FIX_TYPE_2D@{GPS\_\-K\_\-FIX\_\-TYPE\_\-2D}!GPS.h@{GPS.h}}\index{GPS.h@{GPS.h}!GPS_K_FIX_TYPE_2D@{GPS\_\-K\_\-FIX\_\-TYPE\_\-2D}}\item[{\em 
\hypertarget{GPS_8h_a29a18}{
{\em GPS\_\-K\_\-FIX\_\-TYPE\_\-2D}}
\label{GPS_8h_a29a18}
}]GPS fix type = 2D \index{GPS_K_FIX_TYPE_PROPOGATE@{GPS\_\-K\_\-FIX\_\-TYPE\_\-PROPOGATE}!GPS.h@{GPS.h}}\index{GPS.h@{GPS.h}!GPS_K_FIX_TYPE_PROPOGATE@{GPS\_\-K\_\-FIX\_\-TYPE\_\-PROPOGATE}}\item[{\em 
\hypertarget{GPS_8h_a29a19}{
{\em GPS\_\-K\_\-FIX\_\-TYPE\_\-PROPOGATE}}
\label{GPS_8h_a29a19}
}]GPS fix type = Propogate mode \end{description}
\end{Desc}

\hypertarget{GPS_8h_a27}{
\index{GPS.h@{GPS.h}!_GPS_status@{\_\-GPS\_\-status}}
\index{_GPS_status@{\_\-GPS\_\-status}!GPS.h@{GPS.h}}
\subsubsection[\_\-GPS\_\-status]{\setlength{\rightskip}{0pt plus 5cm}enum \_\-GPS\_\-status}}
\label{GPS_8h_a27}


The status codes returned by the GPS facility.

\begin{Desc}
\item[Enumeration values:]\par
\begin{description}
\index{GPS_C_STATUS_ERR_CHECKSUM@{GPS\_\-C\_\-STATUS\_\-ERR\_\-CHECKSUM}!GPS.h@{GPS.h}}\index{GPS.h@{GPS.h}!GPS_C_STATUS_ERR_CHECKSUM@{GPS\_\-C\_\-STATUS\_\-ERR\_\-CHECKSUM}}\item[{\em 
\hypertarget{GPS_8h_a27a8}{
{\em GPS\_\-C\_\-STATUS\_\-ERR\_\-CHECKSUM}}
\label{GPS_8h_a27a8}
}]Checksum error \index{GPS_C_STATUS_ERR_POSTAMBLE@{GPS\_\-C\_\-STATUS\_\-ERR\_\-POSTAMBLE}!GPS.h@{GPS.h}}\index{GPS.h@{GPS.h}!GPS_C_STATUS_ERR_POSTAMBLE@{GPS\_\-C\_\-STATUS\_\-ERR\_\-POSTAMBLE}}\item[{\em 
\hypertarget{GPS_8h_a27a9}{
{\em GPS\_\-C\_\-STATUS\_\-ERR\_\-POSTAMBLE}}
\label{GPS_8h_a27a9}
}]Error in the postamble \index{GPS_C_STATUS_ERR_PREAMBLE@{GPS\_\-C\_\-STATUS\_\-ERR\_\-PREAMBLE}!GPS.h@{GPS.h}}\index{GPS.h@{GPS.h}!GPS_C_STATUS_ERR_PREAMBLE@{GPS\_\-C\_\-STATUS\_\-ERR\_\-PREAMBLE}}\item[{\em 
\hypertarget{GPS_8h_a27a10}{
{\em GPS\_\-C\_\-STATUS\_\-ERR\_\-PREAMBLE}}
\label{GPS_8h_a27a10}
}]Error in the preamble \index{GPS_C_STATUS_ERR_TOO_SHORT@{GPS\_\-C\_\-STATUS\_\-ERR\_\-TOO\_\-SHORT}!GPS.h@{GPS.h}}\index{GPS.h@{GPS.h}!GPS_C_STATUS_ERR_TOO_SHORT@{GPS\_\-C\_\-STATUS\_\-ERR\_\-TOO\_\-SHORT}}\item[{\em 
\hypertarget{GPS_8h_a27a11}{
{\em GPS\_\-C\_\-STATUS\_\-ERR\_\-TOO\_\-SHORT}}
\label{GPS_8h_a27a11}
}]Not enough bytes to read \index{GPS_C_STATUS_ERR_IO@{GPS\_\-C\_\-STATUS\_\-ERR\_\-IO}!GPS.h@{GPS.h}}\index{GPS.h@{GPS.h}!GPS_C_STATUS_ERR_IO@{GPS\_\-C\_\-STATUS\_\-ERR\_\-IO}}\item[{\em 
\hypertarget{GPS_8h_a27a12}{
{\em GPS\_\-C\_\-STATUS\_\-ERR\_\-IO}}
\label{GPS_8h_a27a12}
}]Read/Write error \index{GPS_C_STATUS_OKAY@{GPS\_\-C\_\-STATUS\_\-OKAY}!GPS.h@{GPS.h}}\index{GPS.h@{GPS.h}!GPS_C_STATUS_OKAY@{GPS\_\-C\_\-STATUS\_\-OKAY}}\item[{\em 
\hypertarget{GPS_8h_a27a13}{
{\em GPS\_\-C\_\-STATUS\_\-OKAY}}
\label{GPS_8h_a27a13}
}]Everything is okay \end{description}
\end{Desc}



\subsection{Function Documentation}
\hypertarget{GPS_8h_a25}{
\index{GPS.h@{GPS.h}!GPS_checksum_verify@{GPS\_\-checksum\_\-verify}}
\index{GPS_checksum_verify@{GPS\_\-checksum\_\-verify}!GPS.h@{GPS.h}}
\subsubsection[GPS\_\-checksum\_\-verify]{\setlength{\rightskip}{0pt plus 5cm}int GPS\_\-checksum\_\-verify (const unsigned char {\em buf}\mbox{[}GPS\_\-K\_\-PM\_\-MBF\_\-SIZE\mbox{]})}}
\label{GPS_8h_a25}


Verifies the checksum for the GPS record.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
buf}]The buffer containing the GPS record to verify. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
Status, 0 if else non-zero \end{Desc}
\hypertarget{GPS_8h_a21}{
\index{GPS.h@{GPS.h}!GPS_init@{GPS\_\-init}}
\index{GPS_init@{GPS\_\-init}!GPS.h@{GPS.h}}
\subsubsection[GPS\_\-init]{\setlength{\rightskip}{0pt plus 5cm}int GPS\_\-init (int {\em fd})}}
\label{GPS_8h_a21}


Initializes the GPS device.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
fd}]A previously opened file descriptor to the GPS device \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
Status, 0 if okay, -1 if error. \end{Desc}
\hypertarget{GPS_8h_a20}{
\index{GPS.h@{GPS.h}!GPS_open@{GPS\_\-open}}
\index{GPS_open@{GPS\_\-open}!GPS.h@{GPS.h}}
\subsubsection[GPS\_\-open]{\setlength{\rightskip}{0pt plus 5cm}int GPS\_\-open (const char $\ast$ {\em dev\_\-name})}}
\label{GPS_8h_a20}


Opens a {\em file} descriptor to the GPS device.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
dev\_\-name}]The name of the GPS device. If given as NULL, defaults to \char`\"{}/ty\-Co/1\char`\"{}. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
The file descriptor.\end{Desc}
Separating the open from the initialization allows for some testing. \hypertarget{GPS_8h_a22}{
\index{GPS.h@{GPS.h}!GPS_rate_set@{GPS\_\-rate\_\-set}}
\index{GPS_rate_set@{GPS\_\-rate\_\-set}!GPS.h@{GPS.h}}
\subsubsection[GPS\_\-rate\_\-set]{\setlength{\rightskip}{0pt plus 5cm}int GPS\_\-rate\_\-set (int {\em fd}, int {\em rate})}}
\label{GPS_8h_a22}


Sets the update frequency.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
fd}]A previously opened file descriptor to the GPS device \item[{\em 
rate}]The update rate, in seconds (between 0-255). \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
Status, 0 if okay, -1 if error. \end{Desc}
\hypertarget{GPS_8h_a23}{
\index{GPS.h@{GPS.h}!GPS_read@{GPS\_\-read}}
\index{GPS_read@{GPS\_\-read}!GPS.h@{GPS.h}}
\subsubsection[GPS\_\-read]{\setlength{\rightskip}{0pt plus 5cm}int GPS\_\-read (int {\em fd}, unsigned char {\em buf}\mbox{[}GPS\_\-K\_\-PM\_\-MBF\_\-SIZE\mbox{]})}}
\label{GPS_8h_a23}


Reads the GPS message.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
fd}]The file descriptor to read. \item[{\em 
buf}]The buffer to receive the ASCII message. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
$>$= 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\end{Desc}
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. \hypertarget{GPS_8h_a26}{
\index{GPS.h@{GPS.h}!GPS_utc_get@{GPS\_\-utc\_\-get}}
\index{GPS_utc_get@{GPS\_\-utc\_\-get}!GPS.h@{GPS.h}}
\subsubsection[GPS\_\-utc\_\-get]{\setlength{\rightskip}{0pt plus 5cm}time\_\-t GPS\_\-utc\_\-get (const unsigned char {\em buf}\mbox{[}GPS\_\-K\_\-PM\_\-MBF\_\-SIZE\mbox{]})}}
\label{GPS_8h_a26}


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

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
buf}]The GPS time/position message. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
The UTC time in seconds after 1970 \end{Desc}
\hypertarget{GPS_8h_a24}{
\index{GPS.h@{GPS.h}!GPS_verify@{GPS\_\-verify}}
\index{GPS_verify@{GPS\_\-verify}!GPS.h@{GPS.h}}
\subsubsection[GPS\_\-verify]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{GPS_8h_a1}{GPS\_\-status} GPS\_\-verify (const unsigned char {\em buf}\mbox{[}GPS\_\-K\_\-PM\_\-MBF\_\-SIZE\mbox{]})}}
\label{GPS_8h_a24}


Performs rudimentary checks on the GPS record.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
buf}]The buffer containing the GPS record to verify. \end{description}
\end{Desc}
\begin{Desc}
\item[Return values: ]\par
\begin{description}
\item[{\em 
GPS\_\-C\_\-STATUS\_\-OKAY}]\item[{\em 
GPS\_\-C\_\-STATUS\_\-ERR\_\-PREAMBLE}]\item[{\em 
GPS\_\-C\_\-STATUS\_\-ERR\_\-POSTAMBLE}]\item[{\em 
GPS\_\-C\_\-STATUS\_\-ERR\_\-CHECKSUM}]\end{description}
\end{Desc}
