GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> CTS / dev > cts_scp_enet / linux-gcc


Interface   Data Structures   File List   Data Fields   Globals  

CTS_control.c File Reference

Management of the CTS master control block. More...

#include <string.h>
#include <PBS/MBA.h>
#include <MSG/MSG_pubdefs.h>
#include <ITC/ITC_pubdefs.h>
#include <CTS/CTS_pubdefs.h>
#include <CTS/CTS_msgs.h>
#include <CTS_prvdefs.h>

Functions

static unsigned int checkState (CTS_ControlState creq, CTS_DeviceState dreq, const char *func)
 Check the state of master and task control blocks.
unsigned int CTS_createDevice (void *addr)
 Create and initialize a CTDB (1553) device.
unsigned int CTS_deleteDevice ()
 Delete a CTDB (1553) device.
void * CTS_getDevice ()
 Return the CTDB (1553) device handle.
unsigned int CTS_initialize ()
 Initialize the CTS master control block.
unsigned int CTS_shutdown ()
 Shut down the CTS master control block and release resources.
unsigned int CTS_startDevice ()
 Start a CTDB (1553) device.
unsigned int CTS_stopDevice ()
 Stop a CTDB (1553) device.

Variables

const char * CTS_dev_states [CTS_L_DEV_STATES]
 String constants for CTDB (1553) device.
CTS_ControlCTS_ccb
 Master control block for the CTS system.
const char * CTS_ctl_states [CTS_L_CTL_STATES]
 String constants for CTS control block states.


Detailed Description

Management of the CTS master control block.

CVS $Id: CTS_control.c,v 1.6 2011/03/28 23:55:14 apw Exp $
Author:
A.P.Waite

Function Documentation

static unsigned int checkState ( CTS_ControlState  creq,
CTS_DeviceState  dreq,
const char *  func 
) [inline, static]

Check the state of master and task control blocks.

Parameters:
creq (in) State the CTS master control block must be in
dreq (in) State the CTS service control block must be in
func (in) Name of function calling this routine
Return values:
CTS_CTLSTAT CTS master control block in wrong state for operation
CTS_NOTINIT CTS master control block does not exist
CTS_SUCCESS Success
CTS_SVCHNDL CTS service control block does not exist
CTS_SVCSTAT CTS service control block in wrong state for operation
checkState() is a state integrity checker. It demands that the master control exists and be in state creq, it also demands that the service control block exists and be in state sreq. If these conditions are met, the routine returns CTS_SUCCESS, otherwise it generates a message and returns with a non-CTS_SUCCESS message.

Warning:
If successful, the master control block will be returned with the mutex locked. Any failure and the mutex is returned unlocked.

References _CTS_Device::chk, CRX_svc_states, _CTS_Control::dev, _CTS_Control::mtx, _CTS_Device::state, and _CTS_Control::state.

unsigned int CTS_createDevice ( void *  addr  ) 

Create and initialize a CTDB (1553) device.

Parameters:
addr (in) Address of remote terminal
Return values:
CTS_ALOCFAIL Memory allocation failure
CTS_BADSTAT Not in state "uninitialized" (bad state transition)
CTS_DEVDUP Device already created
CTS_MUALOCFL Cannot allocate a mutex
CTS_SUCCESS Success
CTS_createDevice() creates and initializes a CTDB (1553) device

References _CTS_Device::chk, _CTS_Control::cnt, CTS_CTL_INITIALIZED, CTS_DEV_INITIALIZED, CTS_initDevice(), _CTS_Control::dev, _CTS_Device::loc, _CTS_Control::mtx, _CTS_Device::state, and _CTS_Control::state.

Referenced by CTS_configure().

unsigned int CTS_deleteDevice ( void   ) 

Delete a CTDB (1553) device.

Return values:
CTS_CTLSTAT CTS master control block in wrong state for operation
CTS_DEVACTIV Cannot delete, service task still attached
CTS_NOTINIT CTS master control block does not exist
CTS_SUCCESS Success
CTS_SVCHNDL CTS service control block does not exist
CTS_SVCSTAT CTS service control block in wrong state for operation
CTS_deleteDevice() deletes a CTDB (1553) device

References checkState(), _CTS_Device::chk, _CTS_Control::cnt, _CTS_Control::crx, CRX_L_SVC_TYPES, CRX_SVC_STARTED, CTS_CTL_INITIALIZED, CTS_DEV_INITIALIZED, CTS_DEV_UNINITIALIZED, _CTS_Control::dev, _CTS_Device::loc, _CTS_Control::mtx, _CTS_Device::state, and _CRX_Service::state.

Referenced by CTS_rundown().

void* CTS_getDevice ( void   ) 

Return the CTDB (1553) device handle.

Returns:
The CTDB device handle

References _CTS_Control::dev, and _CTS_Device::loc.

Referenced by CTX_sendCmd().

unsigned int CTS_initialize ( void   ) 

Initialize the CTS master control block.

Return values:
CTS_ALOCFAIL Memory allocation failure
CTS_CTLSTAT CTS master control block in wrong state for operation
CTS_MUALOCFL Cannot allocate a mutex
CTS_SUCCESS Success
CTS_initialize() initializes the CTS master control block.

References CTS_CTL_INITIALIZED, CTS_CTL_UNINITIALIZED, _CTS_Control::mtx, _CTS_Control::rwi, and _CTS_Control::state.

unsigned int CTS_shutdown ( void   ) 

Shut down the CTS master control block and release resources.

Return values:
CTS_DEVACTIV Generic error
CTS_CTLSTAT CTS master control block in wrong state for operation
CTS_NOTINIT CTS master control block does not exist
CTS_SUCCESS Success
CTS_shutdown() shuts down the CTS master control block and releases assocoated resources

References CTS_CTL_INITIALIZED, CTS_CTL_UNINITIALIZED, _CTS_Control::mtx, and _CTS_Control::state.

unsigned int CTS_startDevice ( void   ) 

Start a CTDB (1553) device.

Return values:
CTS_CTLSTAT CTS master control block in wrong state for operation
CTS_NOTINIT CTS master control block does not exist
CTS_SUCCESS Success
CTS_SVCHNDL CTS service control block does not exist
CTS_SVCSTAT CTS service control block in wrong state for operation
CTS_startDevice() starts a CTDB (1553) device

References checkState(), CTS_CTL_INITIALIZED, CTS_DEV_INITIALIZED, CTS_DEV_STARTED, _CTS_Control::dev, _CTS_Device::loc, _CTS_Control::mtx, and _CTS_Device::state.

Referenced by CTS_configure().

unsigned int CTS_stopDevice ( void   ) 

Stop a CTDB (1553) device.

Return values:
CTS_CTLSTAT CTS master control block in wrong state for operation
CTS_NOTINIT CTS master control block does not exist
CTS_SUCCESS Success
CTS_SVCHNDL CTS service control block does not exist
CTS_SVCSTAT CTS service control block in wrong state for operation
CTS_stopDevice() stops a CTDB (1553) device

References checkState(), CTS_CTL_INITIALIZED, CTS_DEV_INITIALIZED, CTS_DEV_STARTED, _CTS_Control::dev, _CTS_Device::loc, _CTS_Control::mtx, and _CTS_Device::state.

Referenced by CTS_rundown().


Variable Documentation

Master control block for the CTS system.

Master control block for the CTS system. This is global, so care must be taken when writing elements of this block that the code is properly protected.

Referenced by checkState(), CRX_createService(), CRX_deleteService(), CRX_recvCmd(), CRX_startService(), CRX_stopService(), CTX_createService(), CTX_deleteService(), CTX_setCmdCallback(), CTX_setTlmCallback(), CTX_startService(), and CTX_stopService().

const char* CTS_ctl_states[CTS_L_CTL_STATES]

Initial value:

{
    "uninitialized",
    "initialized"
}
String constants for CTS control block states.

Referenced by checkState(), CRX_createService(), and CTX_createService().

const char* CTS_dev_states[CTS_L_DEV_STATES]

Initial value:

{
    "uninitialized",
    "initialized",
    "started"
}
String constants for CTDB (1553) device.


Generated on Mon Mar 28 16:58:03 2011 by  doxygen 1.5.8