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


Interface   Data Structures   File List   Data Fields   Globals  

CTX_scp.c File Reference

CTX service callback ("spacecraft" specific). More...

#include <string.h>
#include <PBS/MBA.h>
#include <MSG/MSG_pubdefs.h>
#include <CCSDS/CCSDS_pkt.h>
#include <CTDB/CTDB_config.h>
#include <CTDB/CTDB_bc.h>
#include <ITC/ITC_apidefs.h>
#include <ITC/ITC_drvdefs.h>
#include <ITC/ITC_pubdefs.h>
#include <ITC/ITC_msgs.h>
#include <CTS/CTS_pubdefs.h>
#include <CTS/CTS_msgs.h>
#include <CTS_prvdefs.h>

Functions

static void CTX_freePacket (void *pkt, void *prm)
 Free a queue item.
unsigned int CTX_createService (ITC_TaskID tid, unsigned int nim, ITC_cb_Memory *rtn, void *prm)
 Initialize an CTX service control block.
unsigned int CTX_sendCmd (void *prm, const ITC_QueueItem *qitem, void *pay, unsigned int len)
 Callback for service task sending telecommands to LAT.


Detailed Description

CTX service callback ("spacecraft" specific).

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

Function Documentation

unsigned int CTX_createService ( ITC_TaskID  tid,
unsigned int  nim,
ITC_cb_Memory *  rtn,
void *  prm 
)

Initialize an CTX service control block.

Parameters:
tid (in) ITC task ID for this service
nim (in) Mask of ITC nodes served by this service (not implemented)
rtn (in) Memory allocator for diagnostic stream
prm (in) Memory allocator for diagnostic stream - parameter
Return values:
CTS_SUCCESS Success
CTS_QCREATE Cannot create queue
CTX_createService() creates and intializes an CTX service control block

References _CTS_Control::cnt, CTS_ccb, CTS_CTL_INITIALIZED, CTS_ctl_states, _CTS_Control::ctx, CTX_createQ(), CTX_deleteQ(), CTX_sendCmd(), CTX_SVC_INITIALIZED, _CTS_Control::mtx, and _CTS_Control::state.

Referenced by CTS_configure().

static void CTX_freePacket ( void *  pkt,
void *  prm 
) [static]

Free a queue item.

Parameters:
pkt Packet to free (unused)
prm User context parameter (queue item)

Referenced by CTX_sendCmd().

unsigned int CTX_sendCmd ( void *  prm,
const ITC_QueueItem *  qitem,
void *  pay,
unsigned int  len 
)

Callback for service task sending telecommands to LAT.

Parameters:
prm (in) User context parameter
qitem (in) Queue item
pay (in) Queue item payload pointer
len (in) Queue item payload length
CTX_sendCmd() reads one ITC queue, ITC_QID_CMD, looking for commands that spacecraft side applications want to send to the LAT. Commands are expected to be valid CCSDS packets contained in ITC protocol (though CTX_sendCmd() will check CCSDS integrity, see below).

Warning:
Byte ordering:
  • CTX_sendCmd() requires that incoming packets have their CCSDS header in machine-local byte order.
  • Because the CTDB driver expects the packet in network (big-endian) order, CTX_sendCmd() will perform any necessary byte-swapping on CCSDS headers and checksum fields only. (A service layer routine such as CTX_sendCmd() has no basis to perform CCSDS packet payload byte-swapping).
If any of the following conditions is true, the packet is dropped:
  • Packet size is less than the sum of: a telecommand primary header, a telecommand secondary header, a telecommand checksum.
  • Packet length is greater than a maximum size defined by CTDB_CONFIG_PKT_SIZE_CMD_RX.
  • The packet is an odd number of bytes.
  • The packet is not CCSDS version 1.
  • Packet secondary header bit is clear.
  • Packet command bit is clear.
  • APID is outside the allowed range for telecommands from spacecraft to LAT.
For packets passing these tests, CTX_sendCmd() will:
  • Insert the CCSDS header sequence number (maintained per APID).
  • Calculate and insert the checksum.
  • Do any necessary byte-swapping on headers and checksums.
?????
Return values:
CTX_BADQUEU CTX does not accept packets this queue
CTX_CMDAPID Telecommand APID not in valid range
CTX_CMDBITC Telecommand bit clear in telecommand packet
CTX_CMDEVEN Telecommand packet length not an even number of bytes
CTX_CMDHEAD Telecommand packet header verification failed
CTX_CMDLEN Telecommand packet length not in valid range
CTX_CMDQUEU Error queueing telecommmand packet to CTDB driver
ITC_FORWARD Service completed successfully, do not free packet

References _CTX_Service::cmd, CTS_getDevice(), and CTX_freePacket().

Referenced by CTX_createService().


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