GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> CBIO / V1-0-0 > cbio / mv2304
#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 |
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.
The typedef for _cbio_Device.
| 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.
| name | name of vxworks driver, in the form "/cbio/0", "/cbio/1", etc. | |
| cbFunction | Application callback function. | |
| userData | Application callback function. |
| 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.
| name | name of vxworks driver, in the form "/cbio/0", "/cbio/1", etc. |
| 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.
| 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.
| 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.
| 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 | 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().
| cbioDev | cbio descriptor used by vxWorks kernel. | |
| buffer | read buffer passed by caller. | |
| nBytes | number of bytes requested for write. |
| ERROR | callback not registered or callback failure | |
| OK | success |
References _cbio_Device::callback, and _cbio_Device::userData.
Referenced by CBIO_Drv().
| cbio_driverNum = -1 |
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().
1.5.8