\hypertarget{FCS_8h}{
\section{FCS.h File Reference}
\label{FCS_8h}\index{FCS.h@{FCS.h}}
}
\subsection*{Classes}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__FCS__checksum}{\_\-FCS\_\-checksum}
\begin{CompactList}\small\item\em Structure to hold the context needed when forming the checksum over multiple arrays of data. \item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
typedef struct \hyperlink{struct__FCS__checksum}{\_\-FCS\_\-checksum} \hyperlink{FCS_8h_55683c20d0a1123a8833f5b86d310528}{FCS\_\-checksum}
\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__FCS__checksum}{\_\-FCS\_\-checksum}. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
unsigned int \hyperlink{FCS_8h_5329f8d8d2b5e4e6730fd74964e086a8}{FCS\_\-calculate16} (const unsigned short int $\ast$data, unsigned int cnt)
\begin{CompactList}\small\item\em Calculates the 32-bit Fletcher checksum over the 16-bit {\em data\/} array. \item\end{CompactList}\item 
unsigned int \hyperlink{FCS_8h_6950e18a6008412d69dacc4595801f52}{FCS\_\-calculate32} (const unsigned int $\ast$data, unsigned int cnt)
\begin{CompactList}\small\item\em Calculates the 32-bit Fletcher checksum over the 32-bit {\em data\/} array. \item\end{CompactList}\item 
void \hyperlink{FCS_8h_6ab726e571a1c37f98567f1b2aca67a3}{FCS\_\-construct} (\hyperlink{struct__FCS__checksum}{FCS\_\-checksum} $\ast$checksum)
\begin{CompactList}\small\item\em Constructs a Fletcher checksum context. This is used when the data to be checksummed is {\em not\/} in one contigious array. \item\end{CompactList}\item 
void \hyperlink{FCS_8h_e4f6011c2122688da4a53ad40a325083}{FCS\_\-accumulate16} (\hyperlink{struct__FCS__checksum}{FCS\_\-checksum} $\ast$checksum, const unsigned short int $\ast$data, unsigned int cnt)
\begin{CompactList}\small\item\em Updates the current Fletcher checksum. \item\end{CompactList}\item 
void \hyperlink{FCS_8h_2ccd2ea158d626367eff30e2ab6c8eb2}{FCS\_\-accumulate32} (\hyperlink{struct__FCS__checksum}{FCS\_\-checksum} $\ast$checksum, const unsigned int $\ast$data, unsigned int cnt)
\begin{CompactList}\small\item\em Updates the current Fletcher checksum. \item\end{CompactList}\item 
unsigned int \hyperlink{FCS_8h_e0aa031cc7e68bd45ff68d5fae3e957c}{FCS\_\-get} (const \hyperlink{struct__FCS__checksum}{FCS\_\-checksum} $\ast$checksum)
\begin{CompactList}\small\item\em Processes the Fletcher checksum context, returning the current value of the checksum. \item\end{CompactList}\end{CompactItemize}


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


\footnotesize\begin{verbatim}

   CVS $Id: FCS.h,v 1.1 2009/04/30 00:32:16 russell Exp $
\end{verbatim}
\normalsize


\begin{Desc}
\item[Overview]Routines are provided to compute a 32-bit Fletcher checksum over both arrays of 16-bit and 32-bit integers. In addition, two sets of routines are provided\begin{itemize}
\item simplified routines to a contigious array of 16 or 32-bit integers\item a set of routines to form the checksum over multiple arrays. This is useful if the data to be checksummed is not in contigious memory.\end{itemize}
\end{Desc}
\begin{Desc}
\item[Example, Checksumming multiple arrays.]The following example would form the checksum over 3 arrays,\begin{itemize}
\item {\em array\_\-1\/} of 10 32-bit values\item {\em array\_\-2\/} of 20 32-bit values\item {\em array\_\-3\/} of 30 16-bit values and retrieve the final checksum.\end{itemize}
\end{Desc}


\begin{Code}\begin{verbatim}         FCS_checksum      fcs;
         unsigned int checksum;

         FCS_checksumConstruct (&fcs);
         FCS_checksumUpdate32  (&fcs, array_1, 10);
         FCS_checksumUpdate32  (&fcs, array_2, 20);
         FCS_checksumUpdate16  (&fcs, array_3, 30);

         checksum = FCS_checksumGet (&fcs);
\end{verbatim}
\end{Code}



\begin{Desc}
\item[]Note that this is checksum cannot be computed by separately forming checksums over the 3 arrays and then adding those 3 checksums together. Also note that one may freely mix checksums over 16-bit and 32-bit arrays.\end{Desc}
\begin{Desc}
\item[Implementation note]The 32-bit Fletcher checksum is generally defined to be computed over an array of 16-bit integers. Here the algorithm is adapted to be computed over an array of 32-bit integers. The method is to treat the 32-bit integers as pairs of 16-bit integers. Because the Fletcher checksum is dependent on the ordering of the values being checksummed, one must decide the order to process the pair of 16-bit integers. It was decided to pick the ordering such that on one get the same answer if the 32-bit array was treated as a 16-bit array on a {\em big-endian\/} machine. It is an arbitrary choice, but once choosen must be adherred to when comparing checksums.\end{Desc}
\begin{Desc}
\item[]The code is such that the checksum will be the same when computed on both big and little endian machines. \end{Desc}


\subsection{Typedef Documentation}
\hypertarget{FCS_8h_55683c20d0a1123a8833f5b86d310528}{
\index{FCS.h@{FCS.h}!FCS\_\-checksum@{FCS\_\-checksum}}
\index{FCS\_\-checksum@{FCS\_\-checksum}!FCS.h@{FCS.h}}
\subsubsection[{FCS\_\-checksum}]{\setlength{\rightskip}{0pt plus 5cm}{\bf FCS\_\-checksum}}}
\label{FCS_8h_55683c20d0a1123a8833f5b86d310528}


Typedef for struct \hyperlink{struct__FCS__checksum}{\_\-FCS\_\-checksum}. 

The fields inside this data structure should never be manipulated by the user. The only reason it is provided as part of the public interface is so that the user may conveniently get an instance without doing an allocation. 

\subsection{Function Documentation}
\hypertarget{FCS_8h_e4f6011c2122688da4a53ad40a325083}{
\index{FCS.h@{FCS.h}!FCS\_\-accumulate16@{FCS\_\-accumulate16}}
\index{FCS\_\-accumulate16@{FCS\_\-accumulate16}!FCS.h@{FCS.h}}
\subsubsection[{FCS\_\-accumulate16}]{\setlength{\rightskip}{0pt plus 5cm}void FCS\_\-accumulate16 ({\bf FCS\_\-checksum} $\ast$ {\em checksum}, \/  const unsigned short int $\ast$ {\em data}, \/  unsigned int {\em cnt})}}
\label{FCS_8h_e4f6011c2122688da4a53ad40a325083}


Updates the current Fletcher checksum. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em checksum}]The Fletcher checksum context. \item[{\em data}]The 16-bit data array to add to the current checksum \item[{\em cnt}]The count of elements in {\em data\/} \end{description}
\end{Desc}


References \_\-FCS\_\-checksum::left, \_\-FCS\_\-checksum::sum1, and \_\-FCS\_\-checksum::sum2.\hypertarget{FCS_8h_2ccd2ea158d626367eff30e2ab6c8eb2}{
\index{FCS.h@{FCS.h}!FCS\_\-accumulate32@{FCS\_\-accumulate32}}
\index{FCS\_\-accumulate32@{FCS\_\-accumulate32}!FCS.h@{FCS.h}}
\subsubsection[{FCS\_\-accumulate32}]{\setlength{\rightskip}{0pt plus 5cm}void FCS\_\-accumulate32 ({\bf FCS\_\-checksum} $\ast$ {\em checksum}, \/  const unsigned int $\ast$ {\em data}, \/  unsigned int {\em cnt})}}
\label{FCS_8h_2ccd2ea158d626367eff30e2ab6c8eb2}


Updates the current Fletcher checksum. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em checksum}]The Fletcher checksum context. \item[{\em data}]The 32-bit data array to add to the current checksum \item[{\em cnt}]The count of elements in {\em data\/} \end{description}
\end{Desc}


References dprintf, \_\-FCS\_\-checksum::left, \_\-FCS\_\-checksum::sum1, and \_\-FCS\_\-checksum::sum2.\hypertarget{FCS_8h_5329f8d8d2b5e4e6730fd74964e086a8}{
\index{FCS.h@{FCS.h}!FCS\_\-calculate16@{FCS\_\-calculate16}}
\index{FCS\_\-calculate16@{FCS\_\-calculate16}!FCS.h@{FCS.h}}
\subsubsection[{FCS\_\-calculate16}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int FCS\_\-calculate16 (const unsigned short int $\ast$ {\em data}, \/  unsigned int {\em cnt})}}
\label{FCS_8h_5329f8d8d2b5e4e6730fd74964e086a8}


Calculates the 32-bit Fletcher checksum over the 16-bit {\em data\/} array. 

\begin{Desc}
\item[Returns:]The 32-bit Fletcher checksum\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em data}]The 16-bit data array to checksum \item[{\em cnt}]The count of elements in {\em data\/} \end{description}
\end{Desc}
\hypertarget{FCS_8h_6950e18a6008412d69dacc4595801f52}{
\index{FCS.h@{FCS.h}!FCS\_\-calculate32@{FCS\_\-calculate32}}
\index{FCS\_\-calculate32@{FCS\_\-calculate32}!FCS.h@{FCS.h}}
\subsubsection[{FCS\_\-calculate32}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int FCS\_\-calculate32 (const unsigned int $\ast$ {\em data}, \/  unsigned int {\em cnt})}}
\label{FCS_8h_6950e18a6008412d69dacc4595801f52}


Calculates the 32-bit Fletcher checksum over the 32-bit {\em data\/} array. 

\begin{Desc}
\item[Returns:]The 32-bit Fletcher checksum\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em data}]The 32-bit data array to checksum \item[{\em cnt}]The count of elements in {\em data\/} \end{description}
\end{Desc}


References dprintf.\hypertarget{FCS_8h_6ab726e571a1c37f98567f1b2aca67a3}{
\index{FCS.h@{FCS.h}!FCS\_\-construct@{FCS\_\-construct}}
\index{FCS\_\-construct@{FCS\_\-construct}!FCS.h@{FCS.h}}
\subsubsection[{FCS\_\-construct}]{\setlength{\rightskip}{0pt plus 5cm}void FCS\_\-construct ({\bf FCS\_\-checksum} $\ast$ {\em checksum})}}
\label{FCS_8h_6ab726e571a1c37f98567f1b2aca67a3}


Constructs a Fletcher checksum context. This is used when the data to be checksummed is {\em not\/} in one contigious array. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em checksum}]The Fletcher checksum context to be constructed. \end{description}
\end{Desc}


References \_\-FCS\_\-checksum::left, \_\-FCS\_\-checksum::sum1, and \_\-FCS\_\-checksum::sum2.\hypertarget{FCS_8h_e0aa031cc7e68bd45ff68d5fae3e957c}{
\index{FCS.h@{FCS.h}!FCS\_\-get@{FCS\_\-get}}
\index{FCS\_\-get@{FCS\_\-get}!FCS.h@{FCS.h}}
\subsubsection[{FCS\_\-get}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int FCS\_\-get (const {\bf FCS\_\-checksum} $\ast$ {\em checksum})}}
\label{FCS_8h_e0aa031cc7e68bd45ff68d5fae3e957c}


Processes the Fletcher checksum context, returning the current value of the checksum. 

\begin{Desc}
\item[Returns:]The current value of the 32-bit Fletcher checksum\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em checksum}]The Fletcher checksum context. \end{description}
\end{Desc}


References \_\-FCS\_\-checksum::left, \_\-FCS\_\-checksum::sum1, and \_\-FCS\_\-checksum::sum2.