\hypertarget{cbio_8h}{
\section{cbio.h File Reference}
\label{cbio_8h}\index{cbio.h@{cbio.h}}
}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
typedef int \hyperlink{cbio_8h_a0}{CBIO\_\-Write\-Callback} (const char $\ast$data, int bytes, void $\ast$user\-Data)
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
STATUS \hyperlink{cbio_8h_a1}{CBIO\_\-Create\-Dev} (char $\ast$, \hyperlink{cbio_8h_a0}{CBIO\_\-Write\-Callback} $\ast$, void $\ast$)
\begin{CompactList}\small\item\em Create CBIO device and attach user callback. \item\end{CompactList}\item 
STATUS \hyperlink{cbio_8h_a2}{CBIO\_\-Delete\-Dev} (char $\ast$)
\begin{CompactList}\small\item\em Delete CBIO device and clean up allocation. \item\end{CompactList}\item 
STATUS \hyperlink{cbio_8h_a3}{CBIO\_\-Drv} ()
\begin{CompactList}\small\item\em Initialize CBIO vx\-Works device driver. \item\end{CompactList}\item 
STATUS \hyperlink{cbio_8h_a4}{CBIO\_\-Drv\-Remove} ()
\begin{CompactList}\small\item\em Remove CBIO driver from device table. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
\begin{Desc}
\item[Author:]: Ray Caperoon\end{Desc}
\begin{Desc}
\item[Date:]: Thu Apr 3 10:00:41 2003\end{Desc}
Public header for CBIO module for GLAST. Provides a method for application code to attach a callback to capture/log/telemeter any data printed to stdout or stderr. This is implemented as vxworks driver.

The calling application need to take the following steps to use the CBIO:

1) Install driver with \hyperlink{cbio_8c_a4}{CBIO\_\-Drv()}. This should be done at boot time or application init.

2) Create one or more CBIO devices with \hyperlink{cbio_8c_a6}{CBIO\_\-Create\-Dev()}. By convention, the devices should be named /cbio/0, /cbio/1, etc. When these devices are created, the application supplies a callback function and user data. The callbacks functions are calld when data is written to a CBIO device type. The callback function takes 3 arguments, the data written to the CBIO device, the number of bytes and a user\-Data pointer. This user\-Data pointer is set in the call to \hyperlink{cbio_8c_a6}{CBIO\_\-Create\-Dev()} and is unique to each open CBIO device.

3) Open a CBIO driver with open() to obtain a file descriptor.

4) Use the file descriptor directly or attach to other vx\-Works system resources with log\-Fd\-Add(), io\-Task\-Std\-Set(), etc.

for cleanup:

5) Use close() to close file descriptor.

6) Use \hyperlink{cbio_8c_a7}{CBIO\_\-Delete\-Dev()} to delete the device

7) \hyperlink{cbio_8c_a5}{CBIO\_\-Drv\-Remove()} will remove the driver from the kernel.

The application can create a CBIO device and use vx\-Works functions such as log\-Fd\-Add(), io\-Task\-Std\-Set() or io\-Global\-Std\-Set() to provide a point to capture messages printed to the \char`\"{}screen\char`\"{} or unsolicited output from the vx\-Works kernel.

This driver is only intended for vx\-Works systems. No ports will be supported for other operating systems.

\begin{Desc}
\item[Date]2003/04/10 21:05:00 \end{Desc}
\begin{Desc}
\item[Source]/nfs/slac/g/glast/flight/archive/CBIO/CBIO/cbio.h,v \end{Desc}
\begin{Desc}
\item[Author]ray \end{Desc}
\begin{Desc}
\item[Revision]1.1.1.1 \end{Desc}
\begin{Desc}
\item[Log]\hyperlink{cbio_8h}{cbio.h},v \end{Desc}
Revision 1.1.1.1 2003/04/10 21:05:00 ray Create package CBIO

\subsection{Typedef Documentation}
\hypertarget{cbio_8h_a0}{
\index{cbio.h@{cbio.h}!CBIO_WriteCallback@{CBIO\_\-WriteCallback}}
\index{CBIO_WriteCallback@{CBIO\_\-WriteCallback}!cbio.h@{cbio.h}}
\subsubsection[CBIO\_\-WriteCallback]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{cbio_8h_a0}{CBIO\_\-Write\-Callback}}}
\label{cbio_8h_a0}


The definition of a CBIO write callback function. These callbacks are used when data is written to a CBIO device type. The function takes 3 arguments, the data written to the CBIO device, the number of bytes and a user\-Data pointer. This user\-Data pointer is set in the call to \hyperlink{cbio_8h_a1}{CBIO\_\-Create\-Dev} and is unique to each open CBIO device.



\footnotesize\begin{verbatim}        int CBIO_WriteCallback(const char *data, int bytes, void *userData);
\end{verbatim}\normalsize


\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em data}]A pointer to location of data written to CBIO device. \item[{\em bytes}]Number of bytes written. \item[{\em usr\-Data}]Pointer registered with \hyperlink{cbio_8c_a6}{CBIO\_\-Create\-Dev()}\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em like}]write(), this function will should the number of bytes processed.\end{description}
\end{Desc}


\subsection{Function Documentation}
\hypertarget{cbio_8h_a1}{
\index{cbio.h@{cbio.h}!CBIO_CreateDev@{CBIO\_\-CreateDev}}
\index{CBIO_CreateDev@{CBIO\_\-CreateDev}!cbio.h@{cbio.h}}
\subsubsection[CBIO\_\-CreateDev]{\setlength{\rightskip}{0pt plus 5cm}STATUS CBIO\_\-Create\-Dev (char $\ast$ {\em name}, \hyperlink{cbio_8h_a0}{CBIO\_\-Write\-Callback} $\ast$ {\em cb\-Function}, void $\ast$ {\em user\-Data})}}
\label{cbio_8h_a1}


Create CBIO device and attach user callback. 

\hyperlink{cbio_8c_a6}{CBIO\_\-Create\-Dev()} is used to create a CBIO device. This is also where the application attaches a callback and user data to the device. This function must be called to create a CBIO device.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em name}]name of vxworks driver, in the form \char`\"{}/cbio/0\char`\"{}, \char`\"{}/cbio/1\char`\"{}, etc.\item[{\em cb\-Function}]Application callback function.\item[{\em user\-Data}]Application callback function.\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em OK}]function succeeded\item[{\em FAILED}]CBIO not installed, malloc() or io\-Dev\-Add() failed. \end{description}
\end{Desc}
\hypertarget{cbio_8h_a2}{
\index{cbio.h@{cbio.h}!CBIO_DeleteDev@{CBIO\_\-DeleteDev}}
\index{CBIO_DeleteDev@{CBIO\_\-DeleteDev}!cbio.h@{cbio.h}}
\subsubsection[CBIO\_\-DeleteDev]{\setlength{\rightskip}{0pt plus 5cm}STATUS CBIO\_\-Delete\-Dev (char $\ast$ {\em name})}}
\label{cbio_8h_a2}


Delete CBIO device and clean up allocation. 

\hyperlink{cbio_8c_a7}{CBIO\_\-Delete\-Dev()} is used to delete a CBIO device. The device should be closed before the device is deleted. After removing a device, it cannot be opened until another call to \hyperlink{cbio_8c_a6}{CBIO\_\-Create\-Dev()} is made.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em name}]name of vxworks driver, in the form \char`\"{}/cbio/0\char`\"{}, \char`\"{}/cbio/1\char`\"{}, etc.\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em OK}]function succeeded\item[{\em FAILED}]io\-Dev\-Add failed. \end{description}
\end{Desc}
\hypertarget{cbio_8h_a3}{
\index{cbio.h@{cbio.h}!CBIO_Drv@{CBIO\_\-Drv}}
\index{CBIO_Drv@{CBIO\_\-Drv}!cbio.h@{cbio.h}}
\subsubsection[CBIO\_\-Drv]{\setlength{\rightskip}{0pt plus 5cm}STATUS CBIO\_\-Drv ()}}
\label{cbio_8h_a3}


Initialize CBIO vx\-Works device driver. 

This function is called to register the CBIO device driver with the vx\-Works kernel. If the driver has already been installed (indicated by the module global cbio\_\-driver\-Num being set to -1) this funciton will return error. This function will also fail if ios\-Drv\-Install() fails.

This function should be called soon after (or during) kernel startup. It should only be called once unless \hyperlink{cbio_8c_a5}{CBIO\_\-Drv\-Remove()} is called to unregister the driver.

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em ERROR}]driver already installed or failure of ios\-Drv\-Install()\item[{\em OK}]success \end{description}
\end{Desc}
\hypertarget{cbio_8h_a4}{
\index{cbio.h@{cbio.h}!CBIO_DrvRemove@{CBIO\_\-DrvRemove}}
\index{CBIO_DrvRemove@{CBIO\_\-DrvRemove}!cbio.h@{cbio.h}}
\subsubsection[CBIO\_\-DrvRemove]{\setlength{\rightskip}{0pt plus 5cm}STATUS CBIO\_\-Drv\-Remove ()}}
\label{cbio_8h_a4}


Remove CBIO driver from device table. 

This function is called to unregister the CBIO device driver with the vx\-Works kernel. If the driver has not been installed (indicated by the module global cbio\_\-driver\-Num being set to a value other than -1) this funciton will return error. This function will also fail if ios\-Drv\-Remove() fails.

This function should be called before or during kernel shutdown. It should only be called after \hyperlink{cbio_8c_a4}{CBIO\_\-Drv()} is called to register the CBIO driver.

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em ERROR}]failure of ios\-Drv\-Install() \item[{\em OK}]success \end{description}
\end{Desc}
