\hypertarget{SIV_8c}{
\section{SIV.c File Reference}
\label{SIV_8c}\index{SIV.c@{SIV.c}}
}
The packet state information vector code.  


{\tt \#include $<$SIV.h$>$}\par
{\tt \#include $<$EDS/EBF\_\-pkt.h$>$}\par
{\tt \#include $<$EDS/EBF\_\-edw.h$>$}\par
{\tt \#include $<$PBI/PARITY.ih$>$}\par
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define \hyperlink{SIV_8c_3485ab62b47f9444f831aeeb9281c6e4}{ERR\_\-XFR\_\-BY\_\-XSTATUS}
\begin{CompactList}\small\item\em Bit array giving the {\em ERR\_\-XFR\/} bit as a function of the transfer status field in the event descriptor word. \item\end{CompactList}\item 
\#define \hyperlink{SIV_8c_bf6829951d696d6d82b0e75c0c824ec1}{ERR\_\-XFR}(\_\-xstatus)~((ERR\_\-XFR\_\-BY\_\-XSTATUS $<$$<$ (\_\-xstatus)) \& SIV\_\-M\_\-ERR\_\-XFR)
\begin{CompactList}\small\item\em Translates the event descriptors's transfer status, {\em \_\-xstatus\/} into the corresponding {\em ERR\_\-XFR\/} mask. \item\end{CompactList}\item 
\#define \hyperlink{SIV_8c_4023b8ef0e9db23de49fb146248e4eb2}{MORE\_\-ERR\_\-RCV\_\-BY\_\-RSTATUS}
\begin{CompactList}\small\item\em Bit array giving the {\em MORE\/} and ERR\_\-RCV bit by {\em rstatus\/}. \item\end{CompactList}\item 
\#define \hyperlink{SIV_8c_40d04ce6892533c8e9161e137ea05ead}{MORE\_\-ERR\_\-RCV}(\_\-rstatus)
\begin{CompactList}\small\item\em Translates the event descriptors's receive status, {\em \_\-rstatus\/} into the corresponding {\em MORE\/} and {\em ERR\_\-RCV\/} mask. \item\end{CompactList}\item 
\#define \hyperlink{SIV_8c_4f766c69b2893ac1019fbcaec9834ca7}{ERR\_\-EBM\_\-BY\_\-EBMERR}
\begin{CompactList}\small\item\em Bit array giving 0 or depending on whether the EBM error field contains an error. \item\end{CompactList}\item 
\#define \hyperlink{SIV_8c_88482dbd37ed8ad9d5c965a23d2a7228}{ERR\_\-EBM}(\_\-ebm\_\-err)~(((ERR\_\-EBM\_\-BY\_\-EBMERR $>$$>$ (\_\-ebm\_\-err)) \& 1) $<$$<$ SIV\_\-V\_\-ERR\_\-EBM)
\begin{CompactList}\small\item\em Translates the EBM's 3 bit error field. \item\end{CompactList}\item 
\#define \hyperlink{SIV_8c_ba2de39fcc69acd0cfcabb21cf449e54}{NOTFIRST}(\_\-siv)
\begin{CompactList}\small\item\em Sets the {\em NOTFIRST\/} bit based on the state of the {\em MORE\/} bit in the State Information Vector, {\em \_\-siv\/}. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
\hyperlink{SIV_8h_8e00c41b5b812527c2836dc37a67ef43}{SIV} \hyperlink{SIV_8c_e8d6db6c0a907b6369d4e225f9abc28b}{SIV\_\-init} (void)
\begin{CompactList}\small\item\em Returns an initializes the Packet Reassembly State Information Vector. \item\end{CompactList}\item 
\hyperlink{SIV_8h_8e00c41b5b812527c2836dc37a67ef43}{SIV} \hyperlink{SIV_8c_e3250e73271dacd6d8218352c957fee7}{SIV\_\-update} (\hyperlink{SIV_8h_8e00c41b5b812527c2836dc37a67ef43}{SIV} siv, unsigned int edw, const EBF\_\-pkt $\ast$pkt)
\begin{CompactList}\small\item\em Returns the updated the State Information Vector. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
The packet state information vector code. 

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


\footnotesize\begin{verbatim}
   CVS $Id: SIV.c,v 1.2 2011/03/29 18:49:04 russell Exp $
\end{verbatim}
\normalsize
 

\subsection{Define Documentation}
\hypertarget{SIV_8c_88482dbd37ed8ad9d5c965a23d2a7228}{
\index{SIV.c@{SIV.c}!ERR\_\-EBM@{ERR\_\-EBM}}
\index{ERR\_\-EBM@{ERR\_\-EBM}!SIV.c@{SIV.c}}
\subsubsection[{ERR\_\-EBM}]{\setlength{\rightskip}{0pt plus 5cm}\#define ERR\_\-EBM(\_\-ebm\_\-err)~(((ERR\_\-EBM\_\-BY\_\-EBMERR $>$$>$ (\_\-ebm\_\-err)) \& 1) $<$$<$ SIV\_\-V\_\-ERR\_\-EBM)}}
\label{SIV_8c_88482dbd37ed8ad9d5c965a23d2a7228}


Translates the EBM's 3 bit error field. 

\begin{Desc}
\item[Returns:]The value of the {\em ERR\_\-EBM\/} mask corresponding to the {\em \_\-ebm\_\-err\/} \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-ebm\_\-err}]The EBM's error field \end{description}
\end{Desc}


Referenced by SIV\_\-update().\hypertarget{SIV_8c_4f766c69b2893ac1019fbcaec9834ca7}{
\index{SIV.c@{SIV.c}!ERR\_\-EBM\_\-BY\_\-EBMERR@{ERR\_\-EBM\_\-BY\_\-EBMERR}}
\index{ERR\_\-EBM\_\-BY\_\-EBMERR@{ERR\_\-EBM\_\-BY\_\-EBMERR}!SIV.c@{SIV.c}}
\subsubsection[{ERR\_\-EBM\_\-BY\_\-EBMERR}]{\setlength{\rightskip}{0pt plus 5cm}\#define ERR\_\-EBM\_\-BY\_\-EBMERR}}
\label{SIV_8c_4f766c69b2893ac1019fbcaec9834ca7}


\textbf{Value:}

\begin{Code}\begin{verbatim}( (0 << 0)  /* Success     */           \
                           | (1 << 1)  /* Parity      */           \
                           | (1 << 2)  /* Truncated   */           \
                           | (1 << 3)  /* Write Fault */           \
                           | (1 << 4)  /* Timed out   */           \
                           | (1 << 5)  /* Undefined   */           \
                           | (1 << 6)  /* Undefined   */           \
                           | (1 << 7))
\end{verbatim}
\end{Code}
Bit array giving 0 or depending on whether the EBM error field contains an error. 

\begin{Desc}
\item[]If one shifts this word up by SIV\_\-V\_\-ERR\_\-EBM, the resulting bit will occupy its orresponding position in the {\em SIV\/}.\end{Desc}
\begin{Desc}
\item[Warning:]This word is not made for public consumption. It is only used in support of the ERR\_\-EBM macro. \end{Desc}
\hypertarget{SIV_8c_bf6829951d696d6d82b0e75c0c824ec1}{
\index{SIV.c@{SIV.c}!ERR\_\-XFR@{ERR\_\-XFR}}
\index{ERR\_\-XFR@{ERR\_\-XFR}!SIV.c@{SIV.c}}
\subsubsection[{ERR\_\-XFR}]{\setlength{\rightskip}{0pt plus 5cm}\#define ERR\_\-XFR(\_\-xstatus)~((ERR\_\-XFR\_\-BY\_\-XSTATUS $<$$<$ (\_\-xstatus)) \& SIV\_\-M\_\-ERR\_\-XFR)}}
\label{SIV_8c_bf6829951d696d6d82b0e75c0c824ec1}


Translates the event descriptors's transfer status, {\em \_\-xstatus\/} into the corresponding {\em ERR\_\-XFR\/} mask. 

\begin{Desc}
\item[Returns:]The value of the {\em ERR\_\-XFR\/} mask corresponding to the {\em \_\-xstatus\/} \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-xstatus}]The event descriptor's transfer status \end{description}
\end{Desc}


Referenced by SIV\_\-update().\hypertarget{SIV_8c_3485ab62b47f9444f831aeeb9281c6e4}{
\index{SIV.c@{SIV.c}!ERR\_\-XFR\_\-BY\_\-XSTATUS@{ERR\_\-XFR\_\-BY\_\-XSTATUS}}
\index{ERR\_\-XFR\_\-BY\_\-XSTATUS@{ERR\_\-XFR\_\-BY\_\-XSTATUS}!SIV.c@{SIV.c}}
\subsubsection[{ERR\_\-XFR\_\-BY\_\-XSTATUS}]{\setlength{\rightskip}{0pt plus 5cm}\#define ERR\_\-XFR\_\-BY\_\-XSTATUS}}
\label{SIV_8c_3485ab62b47f9444f831aeeb9281c6e4}


\textbf{Value:}

\begin{Code}\begin{verbatim}((0                  >> 0)                     \
                             |   (SIV_M_ERR_XFR >> 1)                     \
                             |   (SIV_M_ERR_XFR >> 2)                     \
                             |   (SIV_M_ERR_XFR >> 3)                     \
                             |   (SIV_M_ERR_XFR >> 4)                     \
                             |   (SIV_M_ERR_XFR >> 5)                     \
                             |   (SIV_M_ERR_XFR >> 6)                     \
                             |   (SIV_M_ERR_XFR >> 7))                    \
\end{verbatim}
\end{Code}
Bit array giving the {\em ERR\_\-XFR\/} bit as a function of the transfer status field in the event descriptor word. 

\begin{Desc}
\item[]If one shifts this word up xstatus, the ERR\_\-XFR bits will occupy its orresponding position in the {\em SIV\/}.\end{Desc}
\begin{Desc}
\item[Warning:]This word is not made for public consumption. It is only used in support of the ERR\_\-XFR macro. \end{Desc}
\hypertarget{SIV_8c_40d04ce6892533c8e9161e137ea05ead}{
\index{SIV.c@{SIV.c}!MORE\_\-ERR\_\-RCV@{MORE\_\-ERR\_\-RCV}}
\index{MORE\_\-ERR\_\-RCV@{MORE\_\-ERR\_\-RCV}!SIV.c@{SIV.c}}
\subsubsection[{MORE\_\-ERR\_\-RCV}]{\setlength{\rightskip}{0pt plus 5cm}\#define MORE\_\-ERR\_\-RCV(\_\-rstatus)}}
\label{SIV_8c_40d04ce6892533c8e9161e137ea05ead}


\textbf{Value:}

\begin{Code}\begin{verbatim}((MORE_ERR_RCV_BY_RSTATUS << (3 * _rstatus)) &                         \
    (SIV_M_STATE_MORE | SIV_M_ERR_RCV))
\end{verbatim}
\end{Code}
Translates the event descriptors's receive status, {\em \_\-rstatus\/} into the corresponding {\em MORE\/} and {\em ERR\_\-RCV\/} mask. 

\begin{Desc}
\item[Returns:]The value of the {\em MORE\/} and {\em ERR\_\-RCV\/} bits corresponding to the {\em \_\-rstatus\/} \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-rstatus}]The event descriptor receive status \end{description}
\end{Desc}


Referenced by SIV\_\-update().\hypertarget{SIV_8c_4023b8ef0e9db23de49fb146248e4eb2}{
\index{SIV.c@{SIV.c}!MORE\_\-ERR\_\-RCV\_\-BY\_\-RSTATUS@{MORE\_\-ERR\_\-RCV\_\-BY\_\-RSTATUS}}
\index{MORE\_\-ERR\_\-RCV\_\-BY\_\-RSTATUS@{MORE\_\-ERR\_\-RCV\_\-BY\_\-RSTATUS}!SIV.c@{SIV.c}}
\subsubsection[{MORE\_\-ERR\_\-RCV\_\-BY\_\-RSTATUS}]{\setlength{\rightskip}{0pt plus 5cm}\#define MORE\_\-ERR\_\-RCV\_\-BY\_\-RSTATUS}}
\label{SIV_8c_4023b8ef0e9db23de49fb146248e4eb2}


\textbf{Value:}

\begin{Code}\begin{verbatim}/* Status      More     RErr     */     \
    ((0                              >> 3*0)   /*  No       No     */     \
    |((unsigned int)SIV_M_ERR_RCV    >> 3*1)   /*  No      Yes     */     \
    |((unsigned int)SIV_M_ERR_RCV    >> 3*2)   /*  No      Yes     */     \
    |((unsigned int)SIV_M_STATE_MORE >> 3*3))
\end{verbatim}
\end{Code}
Bit array giving the {\em MORE\/} and ERR\_\-RCV bit by {\em rstatus\/}. 

\begin{Desc}
\item[]If one shifts this word up by 2$\ast$rstatus, the {\em MORE\/} and {\em ERR\_\-RCV\/} bits will occupy their corresponding positions in the {\em SIV\/}.\end{Desc}
\begin{Desc}
\item[Warning:]This word is not made for public consumption. It is only used in support of the MORE\_\-ERR\_\-RCV macro. \end{Desc}
\hypertarget{SIV_8c_ba2de39fcc69acd0cfcabb21cf449e54}{
\index{SIV.c@{SIV.c}!NOTFIRST@{NOTFIRST}}
\index{NOTFIRST@{NOTFIRST}!SIV.c@{SIV.c}}
\subsubsection[{NOTFIRST}]{\setlength{\rightskip}{0pt plus 5cm}\#define NOTFIRST(\_\-siv)}}
\label{SIV_8c_ba2de39fcc69acd0cfcabb21cf449e54}


\textbf{Value:}

\begin{Code}\begin{verbatim}((((unsigned int)(_siv)) >>                                             \
     (SIV_V_STATE_MORE - SIV_V_STATE_NOTFIRST))                           \
    & SIV_M_STATE_NOTFIRST)
\end{verbatim}
\end{Code}
Sets the {\em NOTFIRST\/} bit based on the state of the {\em MORE\/} bit in the State Information Vector, {\em \_\-siv\/}. 

\begin{Desc}
\item[Returns:]The new value of the {\em NOTFIRST\/} bit\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-siv}]The State Information Vector \end{description}
\end{Desc}


Referenced by SIV\_\-update().

\subsection{Function Documentation}
\hypertarget{SIV_8c_e8d6db6c0a907b6369d4e225f9abc28b}{
\index{SIV.c@{SIV.c}!SIV\_\-init@{SIV\_\-init}}
\index{SIV\_\-init@{SIV\_\-init}!SIV.c@{SIV.c}}
\subsubsection[{SIV\_\-init}]{\setlength{\rightskip}{0pt plus 5cm}{\bf SIV} SIV\_\-init (void)}}
\label{SIV_8c_e8d6db6c0a907b6369d4e225f9abc28b}


Returns an initializes the Packet Reassembly State Information Vector. 

\begin{Desc}
\item[Returns:]The inialization value of the Packet Reassembly State Information \end{Desc}


Referenced by evtA\_\-0\_\-decode().\hypertarget{SIV_8c_e3250e73271dacd6d8218352c957fee7}{
\index{SIV.c@{SIV.c}!SIV\_\-update@{SIV\_\-update}}
\index{SIV\_\-update@{SIV\_\-update}!SIV.c@{SIV.c}}
\subsubsection[{SIV\_\-update}]{\setlength{\rightskip}{0pt plus 5cm}{\bf SIV} SIV\_\-update ({\bf SIV} {\em siv}, \/  unsigned int {\em edw}, \/  const EBF\_\-pkt $\ast$ {\em pkt})}}
\label{SIV_8c_e3250e73271dacd6d8218352c957fee7}


Returns the updated the State Information Vector. 

\begin{Desc}
\item[Returns:]The updated the State Information Vector\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em siv}]The current value of the State Information Vector \item[{\em edw}]The event descriptor word \item[{\em pkt}]The new EBF packet. This contains the information used to perform the update \end{description}
\end{Desc}


References ERR\_\-EBM, ERR\_\-XFR, MORE\_\-ERR\_\-RCV, NOTFIRST, SIV\_\-M\_\-ERR, SIV\_\-M\_\-STATE\_\-MORE, SIV\_\-M\_\-VAL, SIV\_\-M\_\-VAL\_\-EBMSEQ, SIV\_\-V\_\-ERR\_\-PARITY, SIV\_\-V\_\-ERR\_\-SEQ0, SIV\_\-V\_\-STATE\_\-NOTFIRST, SIV\_\-V\_\-VAL\_\-EBMERR, SIV\_\-V\_\-VAL\_\-EBMSEQ, and SIV\_\-V\_\-VAL\_\-EDWSTATUS.

Referenced by evtA\_\-0\_\-decode().