\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_0fc1cea9c88b77767de902687bb90004}{CBIO\_\-WriteCallback} (const char $\ast$data, int bytes, void $\ast$userData)
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
STATUS \hyperlink{cbio_8h_0dbe265e4955ba0ede1c26dc3566da28}{CBIO\_\-CreateDev} (char $\ast$, \hyperlink{cbio_8h_0fc1cea9c88b77767de902687bb90004}{CBIO\_\-WriteCallback} $\ast$, void $\ast$)
\begin{CompactList}\small\item\em Create CBIO device and attach user callback. \item\end{CompactList}\item 
STATUS \hyperlink{cbio_8h_2863fcebbae82b124cefe737638111f8}{CBIO\_\-DeleteDev} (char $\ast$)
\begin{CompactList}\small\item\em Delete CBIO device and clean up allocation. \item\end{CompactList}\item 
STATUS \hyperlink{cbio_8h_afca3f54e770008dc408b267b301f50e}{CBIO\_\-Drv} ()
\begin{CompactList}\small\item\em Initialize CBIO vxWorks device driver. \item\end{CompactList}\item 
STATUS \hyperlink{cbio_8h_e146bce9995a9aaf3a3b84cbeb74eab1}{CBIO\_\-DrvRemove} ()
\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_8h_afca3f54e770008dc408b267b301f50e}{CBIO\_\-Drv()}. This should be done at boot time or application init.

2) Create one or more CBIO devices with \hyperlink{cbio_8h_0dbe265e4955ba0ede1c26dc3566da28}{CBIO\_\-CreateDev()}. 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 userData pointer. This userData pointer is set in the call to \hyperlink{cbio_8h_0dbe265e4955ba0ede1c26dc3566da28}{CBIO\_\-CreateDev()} 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 vxWorks system resources with logFdAdd(), ioTaskStdSet(), etc.

for cleanup:

5) Use close() to close file descriptor.

6) Use \hyperlink{cbio_8h_2863fcebbae82b124cefe737638111f8}{CBIO\_\-DeleteDev()} to delete the device

7) \hyperlink{cbio_8h_e146bce9995a9aaf3a3b84cbeb74eab1}{CBIO\_\-DrvRemove()} will remove the driver from the kernel.

The application can create a CBIO device and use vxWorks functions such as logFdAdd(), ioTaskStdSet() or ioGlobalStdSet() to provide a point to capture messages printed to the \char`\"{}screen\char`\"{} or unsolicited output from the vxWorks kernel.

This driver is only intended for vxWorks 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_0fc1cea9c88b77767de902687bb90004}{
\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}{\bf CBIO\_\-WriteCallback}}}
\label{cbio_8h_0fc1cea9c88b77767de902687bb90004}


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 userData pointer. This userData pointer is set in the call to \hyperlink{cbio_8c_8db9253eecca619b1c257ea660fb1a68}{CBIO\_\-CreateDev} and is unique to each open CBIO device.



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



\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 usrData}]Pointer registered with \hyperlink{cbio_8h_0dbe265e4955ba0ede1c26dc3566da28}{CBIO\_\-CreateDev()}\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_0dbe265e4955ba0ede1c26dc3566da28}{
\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\_\-CreateDev (char $\ast$ {\em name}, \/  {\bf CBIO\_\-WriteCallback} $\ast$ {\em cbFunction}, \/  void $\ast$ {\em userData})}}
\label{cbio_8h_0dbe265e4955ba0ede1c26dc3566da28}


Create CBIO device and attach user callback. 

\hyperlink{cbio_8h_0dbe265e4955ba0ede1c26dc3566da28}{CBIO\_\-CreateDev()} 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 cbFunction}]Application callback function.\item[{\em userData}]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 ioDevAdd() failed. \end{description}
\end{Desc}


References \_\-cbio\_\-Device::callback, cbio\_\-driverNum, \_\-cbio\_\-Device::devHdr, and \_\-cbio\_\-Device::userData.\hypertarget{cbio_8h_2863fcebbae82b124cefe737638111f8}{
\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\_\-DeleteDev (char $\ast$ {\em name})}}
\label{cbio_8h_2863fcebbae82b124cefe737638111f8}


Delete CBIO device and clean up allocation. 

\hyperlink{cbio_8h_2863fcebbae82b124cefe737638111f8}{CBIO\_\-DeleteDev()} 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_8h_0dbe265e4955ba0ede1c26dc3566da28}{CBIO\_\-CreateDev()} 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}]ioDevAdd failed. \end{description}
\end{Desc}
\hypertarget{cbio_8h_afca3f54e770008dc408b267b301f50e}{
\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_afca3f54e770008dc408b267b301f50e}


Initialize CBIO vxWorks device driver. 

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

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

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em ERROR}]driver already installed or failure of iosDrvInstall()\item[{\em OK}]success \end{description}
\end{Desc}


References cbio\_\-driverNum, cbio\_\-Open(), and cbio\_\-Write().\hypertarget{cbio_8h_e146bce9995a9aaf3a3b84cbeb74eab1}{
\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\_\-DrvRemove ()}}
\label{cbio_8h_e146bce9995a9aaf3a3b84cbeb74eab1}


Remove CBIO driver from device table. 

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

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

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


References cbio\_\-driverNum.