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


Interface   Data Structures   File List   Data Fields   Globals  

CRX_control.c File Reference

The basic control of CTDB driver. More...

#include <string.h>
#include <PBI/Endianness.h>
#include <CCSDS/CCSDS_pkt.h>
#include <PBS/MBA.h>
#include <MSG/MSG_pubdefs.h>
#include <CTS/CTS_pubdefs.h>
#include <CTS/CTS_msgs.h>
#include <CTS_prvdefs.h>

Functions

static unsigned int checkState (CTS_ControlState creq, CRX_ServiceType styp, CRX_ServiceState sreq, const char *func)
 Check the state of master and task control blocks.
static unsigned int validType (CRX_ServiceType typ)
 Validate service type.
static void CRX_recvCmd (void *prm)
 Dispatch telecommand packets arriving at the CTDB device.
unsigned int CRX_createService (CRX_ServiceType typ, CRX_cb_Driver *rtn, void *prm)
 Create a CTDB (1553) receive service block.
unsigned int CRX_deleteService (CRX_ServiceType typ)
 Delete a CTDB (1553) receive service block.
unsigned int CRX_startService (CRX_ServiceType typ, TASK_attr *attr)
 Start a CTDB (1553) receive service.
unsigned int CRX_stopService (CRX_ServiceType typ)
 Start a CTDB (1553) receive service.

Variables

const char * CRX_svc_states [CRX_L_SVC_STATES]
 String constants for CRX service block states.
void * CRX_svcTask [CRX_L_SVC_TYPES]
 Entry points for the receive tasks (by receive service type).


Detailed Description

The basic control of CTDB driver.

CVS $Id: CRX_control.c,v 1.4 2011/03/28 23:55:13 apw Exp $
Author:
D.L.Wood

A.P.Waite


Function Documentation

static unsigned int checkState ( CTS_ControlState  creq,
CRX_ServiceType  styp,
CRX_ServiceState  sreq,
const char *  func 
) [inline, static]

Check the state of master and task control blocks.

Parameters:
creq (in) Required state of CTS master control block
styp (in) Service types
sreq (in) Required state of CRX service control block
func (in) Name of function calling this routine
Return values:
CTS_CTLSTAT CTS master control block not in state initialized
CTS_NOTINIT CTS master control block does not exist
CTS_SUCCESS Success
CTS_SVCSTAT Service not in state undefined
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 _CRX_Service::chk, _CTS_Control::crx, CTS_ccb, CTS_ctl_states, _CTS_Control::mtx, _CRX_Service::state, and _CTS_Control::state.

unsigned int CRX_createService ( CRX_ServiceType  typ,
CRX_cb_Driver rtn,
void *  prm 
)

Create a CTDB (1553) receive service block.

Parameters:
typ (in) Service type (command or telemetry)
rtn (in) Dispatch callback routine
prm (in) Dispatch callback routine parameter
Return values:
CTS_ALOCFAIL Memory allocation failure
CTS_BADSTAT Not in state "uninitialized" (bad state transition)
CTS_MUALOCFL Cannot allocate a mutex
CTS_SUCCESS Success
CRX_createService() allocates and initializes a CTDB (1553) receive service block.

References _CRX_Service::chk, _CTS_Control::cnt, _CTS_Control::crx, CTS_ccb, CTS_CTL_INITIALIZED, CTS_ctl_states, CTX_SVC_INITIALIZED, _CRX_Service::flg, _CTS_Control::mtx, _CRX_Service::prm, _CRX_Service::rtn, _CRX_Service::state, _CTS_Control::state, _CRX_Service::tcb, and validType().

Referenced by CTS_configure().

unsigned int CRX_deleteService ( CRX_ServiceType  typ  ) 

Delete a CTDB (1553) receive service block.

Parameters:
typ (in) Service type (command or telemetry)
Return values:
CTS_BADSTAT Not in state "uninitialized" (bad state transition)
CTS_SUCCESS Success
CRX_deleteService() frees resources associated with a CTDB (1553) receive service block.

References checkState(), _CRX_Service::chk, _CTS_Control::cnt, _CTS_Control::crx, CTS_ccb, CTS_CTL_INITIALIZED, CTX_SVC_INITIALIZED, CTX_SVC_UNINITIALIZED, _CRX_Service::flg, _CTS_Control::mtx, _CRX_Service::prm, _CRX_Service::rtn, _CRX_Service::state, _CRX_Service::tcb, and validType().

Referenced by CTS_rundown().

static void CRX_recvCmd ( void *  prm  )  [static]

Dispatch telecommand packets arriving at the CTDB device.

Parameters:
prm (in) User context parameter
This routine waits for command packets delivered by the CTDB driver. The CTDB driver is assumed to have already done some CCSDS packet validation, specifically:

  • Correct packet alignment (on a two-byte boundary).
  • Correct CCSDS version number (CCSDS version 1, indicated by the value 0 (don't look at me, that's the definition)).
  • Secondary header is true.
  • Packet type is telecommand.
Note that the CTDB driver checks are done without byte swapping the CCSDS header in place, so the header that arrives here is not byte-swapped.

The only thing left to validate is the checksum (not done in the driver because it's running at interrupt level). If the checksum is OK, this routine calls the service routine set up during CRX initialization.

References CTS_ccb, _CTS_Control::dev, _CRX_Service::flg, _CTS_Device::loc, _CRX_Service::prm, and _CRX_Service::rtn.

unsigned int CRX_startService ( CRX_ServiceType  typ,
TASK_attr *  attr 
)

Start a CTDB (1553) receive service.

Parameters:
typ (in) Service type (command or telemetry)
attr (in) Task attributes
Return values:
CTS_BADSTAT Not in state "initialized" (bad state transition)
CTS_NOTINIT Control block has not been allocated/initialized
CTS_SUCCESS Success
CTS_TASKSTRT Cannot start receive task
CRX_startService() starts a CTDB (1553) receive service

References checkState(), _CTS_Control::crx, CRX_SVC_STARTED, CTS_ccb, CTS_CTL_INITIALIZED, CTX_SVC_INITIALIZED, _CTS_Control::dev, _CTS_Control::mtx, _CRX_Service::state, _CRX_Service::tcb, and validType().

Referenced by CTS_configure().

unsigned int CRX_stopService ( CRX_ServiceType  typ  ) 

Start a CTDB (1553) receive service.

Parameters:
typ (in) Service type (command or telemetry)
Return values:
CTS_BADSTAT Not in state "initialized" (bad state transition)
CTS_NOTINIT Control block has not been allocated/initialized
CTS_SUCCESS Success
CTS_TASKSTRT Cannot start receive task
CRX_stopService() stops a CTDB (1553) receive service

References checkState(), _CTS_Control::crx, CTS_ccb, CTS_CTL_INITIALIZED, CTX_SVC_STARTED, _CRX_Service::flg, _CTS_Control::mtx, _CRX_Service::tcb, and validType().

Referenced by CTS_rundown().

static unsigned int validType ( CRX_ServiceType  typ  )  [inline, static]

Validate service type.

Parameters:
typ (in) Service type
Return values:
CTS_RXTYPE Invalid receive service type
CTS_SUCCESS Success
Hide details of type validation (different on LAT and spacecraft sides)

References CRX_TYP_CMD, and CRX_TYP_TLM.

Referenced by CRX_createService(), CRX_deleteService(), CRX_startService(), and CRX_stopService().


Variable Documentation

const char* CRX_svc_states[CRX_L_SVC_STATES]

Initial value:

{
    "uninitialized",
    "initialized",
    "started"
}
String constants for CRX service block states.

Referenced by checkState().

void * CRX_svcTask[CRX_L_SVC_TYPES]

Initial value:

 { &CRX_recvCmd,
                                       &CRX_recvTlm }
Entry points for the receive tasks (by receive service type).


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