\hypertarget{IREC_8c}{
\section{IREC.c File Reference}
\label{IREC_8c}\index{IREC.c@{IREC.c}}
}
{\tt \#include \char`\"{}vx\-Works.h\char`\"{}}\par
{\tt \#include \char`\"{}stdlib.h\char`\"{}}\par
{\tt \#include \char`\"{}stdio.h\char`\"{}}\par
{\tt \#include \char`\"{}log\-Lib.h\char`\"{}}\par
{\tt \#include \char`\"{}sig\-Lib.h\char`\"{}}\par
{\tt \#include \char`\"{}sem\-Lib.h\char`\"{}}\par
{\tt \#include \char`\"{}int\-Lib.h\char`\"{}}\par
{\tt \#include \char`\"{}iv.h\char`\"{}}\par
{\tt \#include \char`\"{}ISOMAX/IREC.h\char`\"{}}\par
{\tt \#include \char`\"{}ISOMAX/ISOMAX.h\char`\"{}}\par
{\tt \#include \char`\"{}MV2X/raven\-Disconnect.h\char`\"{}}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
int \hyperlink{IREC_8c_a4}{IREC\_\-init} (char $\ast$file\-Name, int mode)
\begin{CompactList}\small\item\em Initialize application resources.\item\end{CompactList}\item 
void \hyperlink{IREC_8c_a5}{IREC\_\-exit} (int signal)
\begin{CompactList}\small\item\em Cleaup application resources.\item\end{CompactList}\item 
void \hyperlink{IREC_8c_a6}{IREC\_\-int\-Handler} (void)
\begin{CompactList}\small\item\em Frame sync interrupt handler.\item\end{CompactList}\item 
void \hyperlink{IREC_8c_a7}{IREC} (char $\ast$file\-Name, int mode)
\begin{CompactList}\small\item\em Application main function.\item\end{CompactList}\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
unsigned short \hyperlink{IREC_8c_a0}{IREC\_\-buf} \mbox{[}ISOMAX\_\-FIFO\_\-FRAMES\mbox{]}\mbox{[}ISOMAX\_\-FRAME\_\-WORDS\mbox{]}
\item 
FILE $\ast$ \hyperlink{IREC_8c_a1}{IREC\_\-out} = NULL
\item 
char $\ast$ \hyperlink{IREC_8c_a2}{IREC\_\-out\-Buf} = NULL
\item 
SEM\_\-ID \hyperlink{IREC_8c_a3}{IREC\_\-flag}
\end{CompactItemize}


\subsection{Detailed Description}




\subsection{Function Documentation}
\hypertarget{IREC_8c_a7}{
\index{IREC.c@{IREC.c}!IREC@{IREC}}
\index{IREC@{IREC}!IREC.c@{IREC.c}}
\subsubsection[IREC]{\setlength{\rightskip}{0pt plus 5cm}void IREC (char $\ast$ {\em file\-Name}, int {\em mode})}}
\label{IREC_8c_a7}


Application main function.

After initialization, runs forever pending on the \hyperlink{IREC_8c_a3}{IREC\_\-flag} semaphore. When new data is available, it is written to the \hyperlink{IREC_8c_a1}{IREC\_\-out} file. An incorrectly formatted frame will cause the application to halt.\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
file\-Name}]The name of the output data file. \item[{\em 
mode}]The ISOMAX operational mode. \end{description}
\end{Desc}
\hypertarget{IREC_8c_a5}{
\index{IREC.c@{IREC.c}!IREC_exit@{IREC\_\-exit}}
\index{IREC_exit@{IREC\_\-exit}!IREC.c@{IREC.c}}
\subsubsection[IREC\_\-exit]{\setlength{\rightskip}{0pt plus 5cm}void IREC\_\-exit (int {\em signal})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{IREC_8c_a5}


Cleaup application resources.

This function peforms the following actions to shutdown the application:

\begin{CompactItemize}
\item 
Disables the ISOMAX board.\item 
Closes the BIU\_\-out file.\item 
Frees the output file buffer.\item 
Deletes the \hyperlink{IREC_8c_a3}{IREC\_\-flag} semaphore.\end{CompactItemize}
This function is called when signal SIGTERM is sent to the application.\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
signal}]Ignored. \end{description}
\end{Desc}
\hypertarget{IREC_8c_a4}{
\index{IREC.c@{IREC.c}!IREC_init@{IREC\_\-init}}
\index{IREC_init@{IREC\_\-init}!IREC.c@{IREC.c}}
\subsubsection[IREC\_\-init]{\setlength{\rightskip}{0pt plus 5cm}int IREC\_\-init (char $\ast$ {\em file\-Name}, int {\em mode})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{IREC_8c_a4}


Initialize application resources.

This function peforms the following actions to setup the application for operation:

\begin{CompactItemize}
\item 
Opens the output file \hyperlink{IREC_8c_a1}{IREC\_\-out}.\item 
Allocates a buffer for the output file.\item 
Creates the \hyperlink{IREC_8c_a3}{IREC\_\-flag} semaphore.\item 
Configures the ISOMAX board for receiving frames.\item 
Connects \hyperlink{IREC_8c_a6}{IREC\_\-int\-Handler}() to the \hyperlink{ISOMAX_8h_a24}{ISOMAX\_\-VEC\_\-FIFO} interrupt.\item 
Attaches function \hyperlink{IREC_8c_a5}{IREC\_\-exit}() to the SIGTERM signal.\end{CompactItemize}
\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
file\-Name}]The name of the output data file. \item[{\em 
mode}]The ISOMAX operational mode.\end{description}
\end{Desc}
\begin{Desc}
\item[Return values: ]\par
\begin{description}
\item[{\em 
0}]Success. \item[{\em 
-1}]Failure because a resource could not be created or initialized. \end{description}
\end{Desc}
\hypertarget{IREC_8c_a6}{
\index{IREC.c@{IREC.c}!IREC_intHandler@{IREC\_\-intHandler}}
\index{IREC_intHandler@{IREC\_\-intHandler}!IREC.c@{IREC.c}}
\subsubsection[IREC\_\-intHandler]{\setlength{\rightskip}{0pt plus 5cm}void IREC\_\-int\-Handler (void)\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{IREC_8c_a6}


Frame sync interrupt handler.

This function is attached to the ISOMAX frame sync board receive FIFO half-full interrupt. The newly received data is read into \hyperlink{IREC_8c_a0}{IREC\_\-buf} and the condition signalled through \hyperlink{IREC_8c_a3}{IREC\_\-flag}. 

\subsection{Variable Documentation}
\hypertarget{IREC_8c_a0}{
\index{IREC.c@{IREC.c}!IREC_buf@{IREC\_\-buf}}
\index{IREC_buf@{IREC\_\-buf}!IREC.c@{IREC.c}}
\subsubsection[IREC\_\-buf]{\setlength{\rightskip}{0pt plus 5cm}unsigned short IREC\_\-buf\mbox{[}ISOMAX\_\-FIFO\_\-FRAMES\mbox{]}\mbox{[}ISOMAX\_\-FRAME\_\-WORDS\mbox{]}\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{IREC_8c_a0}


Buffer to hold incomming frame data. \hypertarget{IREC_8c_a3}{
\index{IREC.c@{IREC.c}!IREC_flag@{IREC\_\-flag}}
\index{IREC_flag@{IREC\_\-flag}!IREC.c@{IREC.c}}
\subsubsection[IREC\_\-flag]{\setlength{\rightskip}{0pt plus 5cm}SEM\_\-ID IREC\_\-flag\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{IREC_8c_a3}


Semaphore to signal frame sync FIFO receive condition. \hypertarget{IREC_8c_a1}{
\index{IREC.c@{IREC.c}!IREC_out@{IREC\_\-out}}
\index{IREC_out@{IREC\_\-out}!IREC.c@{IREC.c}}
\subsubsection[IREC\_\-out]{\setlength{\rightskip}{0pt plus 5cm}FILE$\ast$ IREC\_\-out = NULL\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{IREC_8c_a1}


Descriptor for output data file. \hypertarget{IREC_8c_a2}{
\index{IREC.c@{IREC.c}!IREC_outBuf@{IREC\_\-outBuf}}
\index{IREC_outBuf@{IREC\_\-outBuf}!IREC.c@{IREC.c}}
\subsubsection[IREC\_\-outBuf]{\setlength{\rightskip}{0pt plus 5cm}char$\ast$ IREC\_\-out\-Buf = NULL\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{IREC_8c_a2}


Buffer for output file. 