\hypertarget{TDATA_8h}{
\section{TDATA.h File Reference}
\label{TDATA_8h}\index{TDATA.h@{TDATA.h}}
}
Module to create and check a self-describing test data packet. 



This graph shows which files directly or indirectly include this file:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=180pt]{TDATA_8h__dep__incl}
\end{center}
\end{figure}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{TDATA_8h_a0}{
typedef enum \hyperlink{TDATA_8h_a15}{\_\-TDATA\_\-DTEST} \hyperlink{TDATA_8h_a0}{TDATA\_\-DTEST}}
\label{TDATA_8h_a0}

\begin{CompactList}\small\item\em Specifies data sequence for various test. \item\end{CompactList}\end{CompactItemize}
\subsection*{Enumerations}
\begin{CompactItemize}
\item 
enum \hyperlink{TDATA_8h_a15}{\_\-TDATA\_\-DTEST} \{ \par
\hyperlink{TDATA_8h_a15a1}{TDATA\_\-DTEST\_\-INCREMENT} =  0, 
\par
\hyperlink{TDATA_8h_a15a2}{TDATA\_\-DTEST\_\-CONSTANT} =  1, 
\par
\hyperlink{TDATA_8h_a15a3}{TDATA\_\-DTEST\_\-RANDOM} =  2, 
\par
\hyperlink{TDATA_8h_a15a4}{TDATA\_\-DTEST\_\-WALK1} =  3, 
\par
\hyperlink{TDATA_8h_a15a5}{TDATA\_\-DTEST\_\-TRANS01} =  4, 
\par
\hyperlink{TDATA_8h_a15a6}{TDATA\_\-DTEST\_\-TRANS10} =  5, 
\par
\hyperlink{TDATA_8h_a15a7}{TDATA\_\-DTEST\_\-TASKID} =  6
 \}
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{TDATA_8h_a8}{TDATA\_\-create} (unsigned short $\ast$ptr, int len\-In16b, int ccsds, \hyperlink{TDATA_8h_a0}{TDATA\_\-DTEST} test\-Type, unsigned int test\-Parm)
\begin{CompactList}\small\item\em Create a self describing test data buffer. \item\end{CompactList}\item 
int \hyperlink{TDATA_8h_a9}{TDATA\_\-compare} (unsigned short $\ast$ptr, int len\-In16b, int ccsds, int print\-Errs)
\begin{CompactList}\small\item\em Analyse a self describing test data buffer for errors. \item\end{CompactList}\item 
int \hyperlink{TDATA_8h_a10}{TDATA\_\-compare\-Seq} (unsigned short $\ast$ptr, int len\-In16b, int seq, int ccsds, int print\-Errs)
\begin{CompactList}\small\item\em Analyse a buffer segment of a self describing test data buffer for errors. \item\end{CompactList}\item 
void \hyperlink{TDATA_8h_a11}{TDATA\_\-set\-Ccsds\-Parms} (unsigned int app\-Id)
\begin{CompactList}\small\item\em set prameters for all CCSDS packets \item\end{CompactList}\item 
unsigned int \hyperlink{TDATA_8h_a12}{TDATA\_\-get\-Rand\-Ctx\-For\-Seq\-Val} (unsigned int test\-Parm)
\begin{CompactList}\small\item\em Create contex to use with \hyperlink{TDATA_8h_a13}{TDATA\_\-get\-Next\-Seq\-Val()}. \item\end{CompactList}\item 
unsigned int \hyperlink{TDATA_8h_a13}{TDATA\_\-get\-Next\-Seq\-Val} (\hyperlink{TDATA_8h_a0}{TDATA\_\-DTEST} test\-Type, unsigned int test\-Parm, int idx, unsigned int $\ast$rand\-Ctx)
\begin{CompactList}\small\item\em Create a data sequence one word at a time. \item\end{CompactList}\item 
char $\ast$ \hyperlink{TDATA_8h_a14}{TDATA\_\-test\-Str} (\hyperlink{TDATA_8h_a0}{TDATA\_\-DTEST} test\-Type)
\begin{CompactList}\small\item\em convert test type enum to a string \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Module to create and check a self-describing test data packet. 

\begin{Desc}
\item[Author:]Ed Bacho - \href{mailto:ebacho@slac.stanford.edu}{\tt ebacho@slac.stanford.edu}\end{Desc}


\footnotesize\begin{verbatim}\end{verbatim}
\normalsize


\subsection{Enumeration Type Documentation}
\hypertarget{TDATA_8h_a15}{
\index{TDATA.h@{TDATA.h}!_TDATA_DTEST@{\_\-TDATA\_\-DTEST}}
\index{_TDATA_DTEST@{\_\-TDATA\_\-DTEST}!TDATA.h@{TDATA.h}}
\subsubsection[\_\-TDATA\_\-DTEST]{\setlength{\rightskip}{0pt plus 5cm}enum \hyperlink{TDATA_8h_a15}{\_\-TDATA\_\-DTEST}}}
\label{TDATA_8h_a15}


\begin{Desc}
\item[Enumerator: ]\par
\begin{description}
\index{TDATA_DTEST_INCREMENT@{TDATA\_\-DTEST\_\-INCREMENT}!TDATA.h@{TDATA.h}}\index{TDATA.h@{TDATA.h}!TDATA_DTEST_INCREMENT@{TDATA\_\-DTEST\_\-INCREMENT}}\item[{\em 
\hypertarget{TDATA_8h_a15a1}{
TDATA\_\-DTEST\_\-INCREMENT}
\label{TDATA_8h_a15a1}
}]The data increments for each data unit, test\-Parm is start value \index{TDATA_DTEST_CONSTANT@{TDATA\_\-DTEST\_\-CONSTANT}!TDATA.h@{TDATA.h}}\index{TDATA.h@{TDATA.h}!TDATA_DTEST_CONSTANT@{TDATA\_\-DTEST\_\-CONSTANT}}\item[{\em 
\hypertarget{TDATA_8h_a15a2}{
TDATA\_\-DTEST\_\-CONSTANT}
\label{TDATA_8h_a15a2}
}]The data is of constant value, test\-Parm is value \index{TDATA_DTEST_RANDOM@{TDATA\_\-DTEST\_\-RANDOM}!TDATA.h@{TDATA.h}}\index{TDATA.h@{TDATA.h}!TDATA_DTEST_RANDOM@{TDATA\_\-DTEST\_\-RANDOM}}\item[{\em 
\hypertarget{TDATA_8h_a15a3}{
TDATA\_\-DTEST\_\-RANDOM}
\label{TDATA_8h_a15a3}
}]The data changes value randomly, test\-Parm is seed \index{TDATA_DTEST_WALK1@{TDATA\_\-DTEST\_\-WALK1}!TDATA.h@{TDATA.h}}\index{TDATA.h@{TDATA.h}!TDATA_DTEST_WALK1@{TDATA\_\-DTEST\_\-WALK1}}\item[{\em 
\hypertarget{TDATA_8h_a15a4}{
TDATA\_\-DTEST\_\-WALK1}
\label{TDATA_8h_a15a4}
}]The data changes has walking 1's, test\-Parm is number of 1's \index{TDATA_DTEST_TRANS01@{TDATA\_\-DTEST\_\-TRANS01}!TDATA.h@{TDATA.h}}\index{TDATA.h@{TDATA.h}!TDATA_DTEST_TRANS01@{TDATA\_\-DTEST\_\-TRANS01}}\item[{\em 
\hypertarget{TDATA_8h_a15a5}{
TDATA\_\-DTEST\_\-TRANS01}
\label{TDATA_8h_a15a5}
}]The data changes from all 0's to all 1's, test\-Parm is number of 0's before 1's \index{TDATA_DTEST_TRANS10@{TDATA\_\-DTEST\_\-TRANS10}!TDATA.h@{TDATA.h}}\index{TDATA.h@{TDATA.h}!TDATA_DTEST_TRANS10@{TDATA\_\-DTEST\_\-TRANS10}}\item[{\em 
\hypertarget{TDATA_8h_a15a6}{
TDATA\_\-DTEST\_\-TRANS10}
\label{TDATA_8h_a15a6}
}]The data changes from all 1's to all 0's, test\-Parm is number of 1's before 0's \index{TDATA_DTEST_TASKID@{TDATA\_\-DTEST\_\-TASKID}!TDATA.h@{TDATA.h}}\index{TDATA.h@{TDATA.h}!TDATA_DTEST_TASKID@{TDATA\_\-DTEST\_\-TASKID}}\item[{\em 
\hypertarget{TDATA_8h_a15a7}{
TDATA\_\-DTEST\_\-TASKID}
\label{TDATA_8h_a15a7}
}]The data is the creating 32b task\-Id t \end{description}
\end{Desc}



\subsection{Function Documentation}
\hypertarget{TDATA_8h_a9}{
\index{TDATA.h@{TDATA.h}!TDATA_compare@{TDATA\_\-compare}}
\index{TDATA_compare@{TDATA\_\-compare}!TDATA.h@{TDATA.h}}
\subsubsection[TDATA\_\-compare]{\setlength{\rightskip}{0pt plus 5cm}int TDATA\_\-compare (unsigned short $\ast$ {\em ptr}, int {\em len\-In16b}, int {\em ccsds}, int {\em print\-Errs})}}
\label{TDATA_8h_a9}


Analyse a self describing test data buffer for errors. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ptr}]\item[{\em len\-In16b}]\item[{\em ccsds}]1=expect CCSDS header on data \item[{\em print\-Errs}]1=print errors as found \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]number of errors detected\end{Desc}
This checks a data buffer created with \hyperlink{TDATA_8h_a8}{TDATA\_\-create()}. The buffer is assumd to be complete. Buffers broken into sequences should use TDATA\_\-compare\-Seq.

WARNING: Because of the sequence handling, this routine is no longer thread safe. It assumes a single thread is calling it and that sequences of buffer segments are received in order.\hypertarget{TDATA_8h_a10}{
\index{TDATA.h@{TDATA.h}!TDATA_compareSeq@{TDATA\_\-compareSeq}}
\index{TDATA_compareSeq@{TDATA\_\-compareSeq}!TDATA.h@{TDATA.h}}
\subsubsection[TDATA\_\-compareSeq]{\setlength{\rightskip}{0pt plus 5cm}int TDATA\_\-compare\-Seq (unsigned short $\ast$ {\em ptr}, int {\em len\-In16b}, int {\em seq}, int {\em ccsds}, int {\em print\-Errs})}}
\label{TDATA_8h_a10}


Analyse a buffer segment of a self describing test data buffer for errors. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ptr}]The buffer segment to be compared \item[{\em len\-In16b}]length of this seqment \item[{\em seq}]sequence number of this buffer segment where seq=0 is the first \item[{\em ccsds}]1=expect CCSDS header on data \item[{\em print\-Errs}]1=print errors as found \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]number of errors detected\end{Desc}
This checks a data buffer created with \hyperlink{TDATA_8h_a8}{TDATA\_\-create()}. However this routine will alloc one to check the buffer when it is broken into a number segments (as done by the EBM, Event Builder Module). The sequence number of the segment must be specified and seq=0 MUST be first. Info about the buffer is stored staticly on seq=0 and used when seq!=0.

WARNING: Because of the sequence handling, this routine is no longer thread safe. It assumes a single thread is calling it and that sequences of buffer segments are received in order.\hypertarget{TDATA_8h_a8}{
\index{TDATA.h@{TDATA.h}!TDATA_create@{TDATA\_\-create}}
\index{TDATA_create@{TDATA\_\-create}!TDATA.h@{TDATA.h}}
\subsubsection[TDATA\_\-create]{\setlength{\rightskip}{0pt plus 5cm}void TDATA\_\-create (unsigned short $\ast$ {\em ptr}, int {\em len\-In16b}, int {\em ccsds}, \hyperlink{TDATA_8h_a0}{TDATA\_\-DTEST} {\em test\-Type}, unsigned int {\em test\-Parm})}}
\label{TDATA_8h_a8}


Create a self describing test data buffer. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ptr}]\item[{\em len\-In16b}]- total length of buffer including 8 byte header, data, and optional 14 byte CCSDS \item[{\em ccsds}]1=put CCSDS header on data sent out as event \item[{\em test\-Type}]Specifies the data sequence for test \item[{\em test\-Parm}]Parm to use with test\-Type \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]none\end{Desc}
This creates a data buffer with an 8 byte header that describes the data so that \hyperlink{TDATA_8h_a9}{TDATA\_\-compare()} can compare and determine if the data has been corrupted.

The test\-Type and use of test\-Parm is as follows:

test\-Type = TDATA\_\-DTEST\_\-CONSTANT test\-Parm = 16b constant value to be repeated as data

test\-Type = TDATA\_\-DTEST\_\-INCREMENT test\-Parm = 16b start value that is incremented on each 16b word

test\-Type = TDATA\_\-DTEST\_\-RANDOM test\-Parm = seed value for ranom generator, values are 16b but appear random in all d\-Types

test\-Type = TDATA\_\-DTEST\_\-WALK1 test\-Parm = 8=walk on bytes, 16=walk on 16b words, 32=walk on 32b words

test\-Type = TDATA\_\-DTEST\_\-TRANS01 test\-Parm = number of bits of 0's before all 1's in each packet

test\-Type = TDATA\_\-DTEST\_\-TRANS10 test\-Parm = number of bits of 1's before all 0's in each packet\hypertarget{TDATA_8h_a13}{
\index{TDATA.h@{TDATA.h}!TDATA_getNextSeqVal@{TDATA\_\-getNextSeqVal}}
\index{TDATA_getNextSeqVal@{TDATA\_\-getNextSeqVal}!TDATA.h@{TDATA.h}}
\subsubsection[TDATA\_\-getNextSeqVal]{\setlength{\rightskip}{0pt plus 5cm}TDATA\_\-get\-Next\-Seq\-Val (\hyperlink{TDATA_8h_a0}{TDATA\_\-DTEST} {\em test\-Type}, unsigned int {\em test\-Parm}, int {\em idx}, unsigned int $\ast$ {\em rand\-Ctx})}}
\label{TDATA_8h_a13}


Create a data sequence one word at a time. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em test\-Type}]type of data sequence \item[{\em test\-Parm}]parm for data sequence \item[{\em idx}]index into sequence \item[{\em rand\-Ctx}]if test\-Type==TDATA\_\-DTEST\_\-RANDOM, supply pointer to int returned from \hyperlink{TDATA_8h_a12}{TDATA\_\-get\-Rand\-Ctx\-For\-Seq\-Val()} \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]data value in sequence\end{Desc}
Create a data sequence one word at a time. TDATA\_\-init\-Seq() needs to be called first.\hypertarget{TDATA_8h_a12}{
\index{TDATA.h@{TDATA.h}!TDATA_getRandCtxForSeqVal@{TDATA\_\-getRandCtxForSeqVal}}
\index{TDATA_getRandCtxForSeqVal@{TDATA\_\-getRandCtxForSeqVal}!TDATA.h@{TDATA.h}}
\subsubsection[TDATA\_\-getRandCtxForSeqVal]{\setlength{\rightskip}{0pt plus 5cm}TDATA\_\-get\-Rand\-Ctx\-For\-Seq\-Val (unsigned int {\em seed})}}
\label{TDATA_8h_a12}


Create contex to use with \hyperlink{TDATA_8h_a13}{TDATA\_\-get\-Next\-Seq\-Val()}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em seed}]seed value for random number generator \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]contex to be used for random number generator\end{Desc}
\hypertarget{TDATA_8h_a11}{
\index{TDATA.h@{TDATA.h}!TDATA_setCcsdsParms@{TDATA\_\-setCcsdsParms}}
\index{TDATA_setCcsdsParms@{TDATA\_\-setCcsdsParms}!TDATA.h@{TDATA.h}}
\subsubsection[TDATA\_\-setCcsdsParms]{\setlength{\rightskip}{0pt plus 5cm}void TDATA\_\-set\-Ccsds\-Parms (unsigned int {\em app\-Id})}}
\label{TDATA_8h_a11}


set prameters for all CCSDS packets 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em app\-Id}]set the App\-Id fiels within CCSDS header \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]none\end{Desc}
\hypertarget{TDATA_8h_a14}{
\index{TDATA.h@{TDATA.h}!TDATA_testStr@{TDATA\_\-testStr}}
\index{TDATA_testStr@{TDATA\_\-testStr}!TDATA.h@{TDATA.h}}
\subsubsection[TDATA\_\-testStr]{\setlength{\rightskip}{0pt plus 5cm}const char $\ast$ TDATA\_\-test\-Str (\hyperlink{TDATA_8h_a0}{TDATA\_\-DTEST} {\em test\-Type})}}
\label{TDATA_8h_a14}


convert test type enum to a string 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em test\-Type}]enum to turn to string \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]string of given enum\end{Desc}
