GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> CBIO / V1-0-0 > cbio / mv2304


Interface   Data Structures   File List   Data Fields   Globals  

cbio.c File Reference

#include <vxWorks.h>
#include <iosLib.h>
#include <stdlib.h>
#include <errnoLib.h>
#include "CBIO/cbio.h"

Classes

struct  _cbio_Device

Typedefs

typedef struct _cbio_Device cbio_Device

Functions

static STATUS cbio_Open (cbio_Device *cbioDev, char *remainder, int mode)
 vxWorks device driver open function.
static STATUS cbio_Write (cbio_Device *cbioDev, char *buffer, int nBytes)
 vxWorks device driver write function.
STATUS CBIO_Drv ()
 Initialize CBIO vxWorks device driver.
STATUS CBIO_DrvRemove ()
 Remove CBIO driver from device table.
STATUS CBIO_CreateDev (char *name, CBIO_WriteCallback *cbFunction, void *userData)
 Create CBIO device and attach user callback.
STATUS CBIO_DeleteDev (char *name)
 Delete CBIO device and clean up allocation.

Variables

LOCAL int cbio_driverNum = -1

Detailed Description

Author:
: Ray Caperoon
Date:
: Thu Apr 3 10:00:33 2003
Implementation of 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 CBIO_Drv(). This should be done at boot time or application init.

2) Create one or more CBIO devices with 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 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 CBIO_DeleteDev() to delete the device

7) 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 "screen" or unsolicited output from the vxWorks kernel.

This driver is only intended for vxWorks systems. No ports will be supported for other operating systems.

Date
2003/04/10 21:05:00
Source
/nfs/slac/g/glast/flight/archive/CBIO/src/cbio.c,v
Author
ray
Revision
1.1.1.1
Log
cbio.c,v
Revision 1.1.1.1 2003/04/10 21:05:00 ray Create package CBIO

Typedef Documentation

The typedef for _cbio_Device.


Function Documentation

STATUS CBIO_CreateDev ( char *  name,
CBIO_WriteCallback cbFunction,
void *  userData 
)

Create CBIO device and attach user callback.

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.

Parameters:
name name of vxworks driver, in the form "/cbio/0", "/cbio/1", etc.
cbFunction Application callback function.
userData Application callback function.
Return values:
OK function succeeded
FAILED CBIO not installed, malloc() or ioDevAdd() failed.

References _cbio_Device::callback, cbio_driverNum, _cbio_Device::devHdr, and _cbio_Device::userData.

STATUS CBIO_DeleteDev ( char *  name  ) 

Delete CBIO device and clean up allocation.

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 CBIO_CreateDev() is made.

Parameters:
name name of vxworks driver, in the form "/cbio/0", "/cbio/1", etc.
Return values:
OK function succeeded
FAILED ioDevAdd failed.

STATUS CBIO_Drv (  ) 

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 CBIO_DrvRemove() is called to unregister the driver.

Return values:
ERROR driver already installed or failure of iosDrvInstall()
OK success

References cbio_driverNum, cbio_Open(), and cbio_Write().

STATUS CBIO_DrvRemove (  ) 

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 CBIO_Drv() is called to register the CBIO driver.

Return values:
ERROR failure of iosDrvInstall()
OK success

References cbio_driverNum.

STATUS cbio_Open ( cbio_Device cbioDev,
char *  remainder,
int  mode 
) [static]

vxWorks device driver open function.

This function is registered with the kernel I/O system as the OPEN function. When a CBIO device is open()'ed, this function will be called. The CBIO is a simple device so the open function does nothing but indicate success.

Parameters:
cbioDev cbio descriptor used by vxWorks kernel.
remainder not used. needed to comform to vxWorks device structure.
mode not used. needed to comform to vxWorks device structure.
Return values:
return value is bogus

Referenced by CBIO_Drv().

STATUS cbio_Write ( cbio_Device cbioDev,
char *  buffer,
int  nBytes 
) [static]

vxWorks device driver write function.

Called when data is written to cbio device. Passes data on to user callback. If no user callback has been registered, ERROR is returned. The error status should make it's way back to the original caller of write() or printf().

Parameters:
cbioDev cbio descriptor used by vxWorks kernel.
buffer read buffer passed by caller.
nBytes number of bytes requested for write.
Return values:
ERROR callback not registered or callback failure
OK success

References _cbio_Device::callback, and _cbio_Device::userData.

Referenced by CBIO_Drv().


Variable Documentation

CBIO driver number. Returned by VxWorks IOS facility. A global variable that tracks the index of the drivr in the kernel driver table. Set to -1 when driver is not installed (initialization and calls to CBIO_DrvRemove set it to -1).

Referenced by CBIO_CreateDev(), CBIO_Drv(), and CBIO_DrvRemove().


Generated on Wed Nov 21 22:05:17 2012 by  doxygen 1.5.8