\hypertarget{BIUSIM_8c}{
\section{BIUSIM.c File Reference}
\label{BIUSIM_8c}\index{BIUSIM.c@{BIUSIM.c}}
}
{\tt \#include \char`\"{}stdio.h\char`\"{}}\par
{\tt \#include \char`\"{}string.h\char`\"{}}\par
{\tt \#include \char`\"{}netdb.h\char`\"{}}\par
{\tt \#include \char`\"{}sys/socket.h\char`\"{}}\par
{\tt \#include \char`\"{}sys/select.h\char`\"{}}\par
{\tt \#include \char`\"{}netinet/in.h\char`\"{}}\par
{\tt \#include \char`\"{}arpa/inet.h\char`\"{}}\par
{\tt \#include \char`\"{}ctype.h\char`\"{}}\par
{\tt \#include \char`\"{}BIU/BIUSIM.h\char`\"{}}\par
{\tt \#include \char`\"{}BIUD/BIUD\_\-port.h\char`\"{}}\par
{\tt \#include \char`\"{}CCSDS/CCSDS\_\-pkt.h\char`\"{}}\par
{\tt \#include \char`\"{}CCSDS/CCSDS\_\-bfem.h\char`\"{}}\par
{\tt \#include \char`\"{}TRX/TRX\_\-port.h\char`\"{}}\par
{\tt \#include \char`\"{}BIU\_\-telem\_\-private.h\char`\"{}}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
int \hyperlink{BIUSIM_8c_a5}{BIUSIM\_\-init} (int argc, char $\ast$$\ast$argv)
\begin{CompactList}\small\item\em Initialize application resources.\item\end{CompactList}\item 
void \hyperlink{BIUSIM_8c_a6}{BIUSIM\_\-send} (int size)
\begin{CompactList}\small\item\em Send a telemetry packet to the GSE host.\item\end{CompactList}\item 
int \hyperlink{BIUSIM_8c_a7}{main} (int argc, char $\ast$$\ast$argv)
\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
unsigned short \hyperlink{BIUSIM_8c_a0}{BIUSIM\_\-pkt\-Buf} \mbox{[}BIU\_\-TELEM\_\-PKT\_\-MAX\_\-WORDS\mbox{]}
\item 
int \hyperlink{BIUSIM_8c_a1}{BIUSIM\_\-hkp\-Recv\-Socket}
\item 
int \hyperlink{BIUSIM_8c_a2}{BIUSIM\_\-event\-Recv\-Socket}
\item 
int \hyperlink{BIUSIM_8c_a3}{BIUSIM\_\-send\-Socket}
\item 
sockaddr\_\-in \hyperlink{BIUSIM_8c_a4}{BIUSIM\_\-send\-Addr}
\end{CompactItemize}


\subsection{Detailed Description}




\subsection{Function Documentation}
\hypertarget{BIUSIM_8c_a5}{
\index{BIUSIM.c@{BIUSIM.c}!BIUSIM_init@{BIUSIM\_\-init}}
\index{BIUSIM_init@{BIUSIM\_\-init}!BIUSIM.c@{BIUSIM.c}}
\subsubsection[BIUSIM\_\-init]{\setlength{\rightskip}{0pt plus 5cm}int BIUSIM\_\-init (int {\em argc}, char $\ast$$\ast$ {\em argv})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BIUSIM_8c_a5}


Initialize application resources.

This function peforms the following actions to setup the {\tt BIUSIM} application for operation:

\begin{CompactItemize}
\item 
Verifies the correct number of command line arguments.\item 
Creates the \hyperlink{BIUSIM_8c_a1}{BIUSIM\_\-hkp\-Recv\-Socket} socket.\item 
Creates the \hyperlink{BIUSIM_8c_a2}{BIUSIM\_\-event\-Recv\-Socket} socket.\item 
Binds \hyperlink{BIUSIM_8c_a1}{BIUSIM\_\-hkp\-Recv\-Socket} to port number BIU\_\-PORT\_\-DAQ\_\-HKP.\item 
Binds \hyperlink{BIUSIM_8c_a2}{BIUSIM\_\-event\-Recv\-Socket} to port number BIU\_\-PORT\_\-DAQ\_\-EVENT.\item 
Lookup the IP address of the GSE host (command line argument \#1).\item 
Creates the \hyperlink{BIUSIM_8c_a3}{BIUSIM\_\-send\-Socket} socket.\end{CompactItemize}
\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
argc}]The number of command line arguments. \item[{\em 
argv}]Pointers to the command line arguments.\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{BIUSIM_8c_a6}{
\index{BIUSIM.c@{BIUSIM.c}!BIUSIM_send@{BIUSIM\_\-send}}
\index{BIUSIM_send@{BIUSIM\_\-send}!BIUSIM.c@{BIUSIM.c}}
\subsubsection[BIUSIM\_\-send]{\setlength{\rightskip}{0pt plus 5cm}void BIUSIM\_\-send (int {\em size})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BIUSIM_8c_a6}


Send a telemetry packet to the GSE host.

After verification, sends the CCSDS telemetry packet in \hyperlink{BIUSIM_8c_a0}{BIUSIM\_\-pkt\-Buf} out on  \hyperlink{BIUSIM_8c_a3}{BIUSIM\_\-send\-Socket}.\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
size}]The packet size as reported by UDP. \end{description}
\end{Desc}
\hypertarget{BIUSIM_8c_a7}{
\index{BIUSIM.c@{BIUSIM.c}!main@{main}}
\index{main@{main}!BIUSIM.c@{BIUSIM.c}}
\subsubsection[main]{\setlength{\rightskip}{0pt plus 5cm}int main (int {\em argc}, char $\ast$$\ast$ {\em argv})}}
\label{BIUSIM_8c_a7}


After initializing resources, the main application function listens for incomming telemetry packets on \hyperlink{BIUSIM_8c_a1}{BIUSIM\_\-hkp\-Recv\-Socket}. After verifcation, the  CCSDS header is stripped and the packet data is written to \hyperlink{BIUSIM_8c_a3}{BIUSIM\_\-send\-Socket}.\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
argc}]The number of command line arguments. \item[{\em 
argv}]Pointers to the command line arguments. \end{description}
\end{Desc}


\subsection{Variable Documentation}
\hypertarget{BIUSIM_8c_a2}{
\index{BIUSIM.c@{BIUSIM.c}!BIUSIM_eventRecvSocket@{BIUSIM\_\-eventRecvSocket}}
\index{BIUSIM_eventRecvSocket@{BIUSIM\_\-eventRecvSocket}!BIUSIM.c@{BIUSIM.c}}
\subsubsection[BIUSIM\_\-eventRecvSocket]{\setlength{\rightskip}{0pt plus 5cm}int BIUSIM\_\-event\-Recv\-Socket\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BIUSIM_8c_a2}


A UDP socket for receiving housekeeping event packets from the DAQ \hypertarget{BIUSIM_8c_a1}{
\index{BIUSIM.c@{BIUSIM.c}!BIUSIM_hkpRecvSocket@{BIUSIM\_\-hkpRecvSocket}}
\index{BIUSIM_hkpRecvSocket@{BIUSIM\_\-hkpRecvSocket}!BIUSIM.c@{BIUSIM.c}}
\subsubsection[BIUSIM\_\-hkpRecvSocket]{\setlength{\rightskip}{0pt plus 5cm}int BIUSIM\_\-hkp\-Recv\-Socket\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BIUSIM_8c_a1}


A UDP socket for receiving housekeeping telemetry packets from the DAQ \hypertarget{BIUSIM_8c_a0}{
\index{BIUSIM.c@{BIUSIM.c}!BIUSIM_pktBuf@{BIUSIM\_\-pktBuf}}
\index{BIUSIM_pktBuf@{BIUSIM\_\-pktBuf}!BIUSIM.c@{BIUSIM.c}}
\subsubsection[BIUSIM\_\-pktBuf]{\setlength{\rightskip}{0pt plus 5cm}unsigned short BIUSIM\_\-pkt\-Buf\mbox{[}BIU\_\-TELEM\_\-PKT\_\-MAX\_\-WORDS\mbox{]}\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BIUSIM_8c_a0}


A buffer to receive incomming DAQ telemetry packets. \hypertarget{BIUSIM_8c_a4}{
\index{BIUSIM.c@{BIUSIM.c}!BIUSIM_sendAddr@{BIUSIM\_\-sendAddr}}
\index{BIUSIM_sendAddr@{BIUSIM\_\-sendAddr}!BIUSIM.c@{BIUSIM.c}}
\subsubsection[BIUSIM\_\-sendAddr]{\setlength{\rightskip}{0pt plus 5cm}struct sockaddr\_\-in BIUSIM\_\-send\-Addr\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BIUSIM_8c_a4}


A UDP/IP address structure for the GSE host machine. \hypertarget{BIUSIM_8c_a3}{
\index{BIUSIM.c@{BIUSIM.c}!BIUSIM_sendSocket@{BIUSIM\_\-sendSocket}}
\index{BIUSIM_sendSocket@{BIUSIM\_\-sendSocket}!BIUSIM.c@{BIUSIM.c}}
\subsubsection[BIUSIM\_\-sendSocket]{\setlength{\rightskip}{0pt plus 5cm}int BIUSIM\_\-send\-Socket\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BIUSIM_8c_a3}


A UDP socket for sending telemetry packets to the GSE 