GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> QSD / dev > qsdccsds / rhel6-64


Interface   Data Structures   File List   Data Fields   Globals  

CCSDS_apidDsc.h File Reference

CCSDS APID input stream descriptor (interface). More...


Classes

struct  _CCSDS_apidDscNode
 APID Descriptor node. More...
struct  _CCSDS_apidHandlers
 The list handlers for the APID. More...
struct  _CCSDS_apidDsc
 Description of a packet for a specified APID. More...

Typedefs

typedef struct _CCSDS_header CCSDS_header
 Typedef for struct _CCSDS_header.
typedef struct _CCSDS_apidDscTbl CCSDS_apidDscTbl
 Typedef for struct _CCSDS_apidDscTbl.
typedef struct _CCSDS_apidDscNode CCSDS_apidDscNode
 Typedef for _CCSDS_apidDscNode.
typedef struct _CCSDS_apidHandlers CCSDS_apidHandlers
 Typedef for struct _CCSDS_apidHandlers.
typedef struct _CCSDS_apidDsc CCSDS_apidDsc
 Typedef for struct _CCSDS_apidDsc.
typedef struct _CCSDS_telemetry CCSDS_telemetry
typedef enum
_CCSDS_APIDDSC_BRIDGE_K 
CCSDS_APIDDSC_BRIDGE_K
 Typedef for enum _CCSDS_APIDDSC_BRIDGE_K.
typedef enum _CCSDS_APIDDSC_K CCSDS_APIDDSC_K
 Typedef for enum _CCSDS_APIDDSC_K.
typedef int(* CCSDS_packetChecker )(void *ctx, void *stream, const CCSDS_telemetry *pkt, CCSDS_apidDsc *dsc)
 This routine is callback immediately after a CCSDS packet has been read.
typedef int(* CCSDS_payloadProcessor )(void *ctx, const void *payload, int nbytes)
 User callback routine to process the fully assembled payload of a sequence of CCSDS packets.
typedef enum _CCSDS_APIDDSC_POPTS_V CCSDS_APIDDSC_POPTS_V
 Typedef for enum _CCSDS_APIDDSC_POPTS_V.
typedef enum _CCSDS_APIDDSC_POPTS_M CCSDS_APIDDSC_POPTS_M
 Typedef for enum _CCSDS_APIDDSC_POPTS_M.

Enumerations

enum  _CCSDS_APIDDSC_BRIDGE_K {
  CCSDS_APIDDSC_BRIDGE_K_PAYLOAD = 0,
  CCSDS_APIDDSC_BRIDGE_K_HEADER = 1,
  CCSDS_APIDDSC_BRIDGE_K_RSVD_2 = 2,
  CCSDS_APIDDSC_BRIDGE_K_PAD = 3
}
 Enumerates how the odd 16-bit word, hereafter called the bridge word, that follows the normal 7 x 16-bit CCSDS header is to be treated. More...
enum  _CCSDS_APIDDSC_K { CCSDS_APIDDSC_K_SEQ_RESET = 0xffff }
 Encapsulates known constants of the Apid Descriptor. More...
enum  _CCSDS_APIDDSC_POPTS_V {
  CCSDS_APIDDSC_POPTS_V_CHECKER = 0,
  CCSDS_APIDDSC_POPTS_V_PROCESSOR = 1,
  CCSDS_APIDDSC_POPTS_V_SWAP = 2
}
 Processing options, right shifts. More...
enum  _CCSDS_APIDDSC_POPTS_M {
  CCSDS_APIDDSC_POPTS_M_CHECKER = (1 << CCSDS_APIDDSC_POPTS_V_CHECKER),
  CCSDS_APIDDSC_POPTS_M_PROCESSOR = (1 << CCSDS_APIDDSC_POPTS_V_PROCESSOR),
  CCSDS_APIDDSC_POPTS_M_SWAP = (1 << CCSDS_APIDDSC_POPTS_V_SWAP)
}
 Processing options, inplace masks. More...

Functions

int CCSDS_apidDscRegister (CCSDS_apidDscTbl *tbl, CCSDS_apidDsc *dsc, void *ctx, unsigned short int apid, CCSDS_APIDDSC_BRIDGE_K bridge, unsigned char *buf, unsigned int buf_size)
 Registers an APID descriptor.
void CCSDS_apidDscConstruct (CCSDS_apidDsc *dsc, void *ctx, unsigned short int apid, CCSDS_APIDDSC_BRIDGE_K bridge, unsigned char *buf, unsigned int buf_size)
 Constructs (initializes) an CCSDS_apidDsc, an APID descriptor.
void CCSDS_apidDscReset (CCSDS_apidDsc *dsc)
 Resets the specified APID descriptor to its initial state. This routine is used mainly for error recovery.
CCSDS_apidDscCCSDS_apidDscFind (CCSDS_apidDscTbl *tbl, const CCSDS_header *hdr)
 Built-in method to locate the descriptor associated with the specified APID as read from the header.
int CCSDS_apidDscSwap32 (CCSDS_apidDsc *dsc)
 Convenience routine to 32-bit swap all the words in the current buffer, presumed to be in a big-endian, to the local representation.
int CCSDS_apidDscSwap16 (CCSDS_apidDsc *dsc)
 Convenience routine to 16-bit swap all the words in the current buffer, presumed to be in a big-endian, to the local representation.
static __inline const void * CCSDS_apidDscPktBeg (const CCSDS_apidDsc *dsc)
 Returns a pointer to the beginning of the current LDF datagram.
static __inline const void * CCSDS_apidDscPktEnd (const CCSDS_apidDsc *dsc)
 Returns a pointer to the end (actually one bytes past the end) of the current LDF datagram.
static __inline int CCSDS_apidDscPktLen (const CCSDS_apidDsc *dsc)
 Returns the length, in bytes, of the current LDF record.
static __inline void CCSDS_apidDscSeqReset (CCSDS_apidDsc *dsc)
 Resets the sequence number to indicate that the next packet encountered is the first. Since the sequence number of the first packet to be processed is unknown, this effectively disables the sequence checking.
static __inline void CCSDS_apidDscSeqSet (CCSDS_apidDsc *dsc, unsigned short int seq)
 Sets the sequence number to the indicated value. This routine is only of interested when trying to resynch to a stream.
static __inline void CCSDS_apidDscPacketCheckerSet (CCSDS_apidDsc *dsc, int enb, CCSDS_packetChecker rtn, void *ctx)
 Establishes the packet checking routine. This routine is called to verify the integrity of a just read CCSDS packet.
static __inline void CCSDS_apidDscPayloadProcessorSet (CCSDS_apidDsc *dsc, int enb, CCSDS_payloadProcessor rtn, void *ctx)
 Establishes the payload processing routine. This routine is called when the payload of all CCSDS packets have been assembled. Enabling the SWAP option will 32-bit swap the payload before handing it to the user.
static __inline void CCSDS_apidDscPoptsEnable (CCSDS_apidDsc *dsc, unsigned int popt)
 Enables the specified set of processing options,.
static __inline void CCSDS_apidDscPoptsDisable (CCSDS_apidDsc *dsc, unsigned int popt)
 Disables the specified set of processing options,.
static __inline void CCSDS_apidDscPoptsSet (CCSDS_apidDsc *dsc, unsigned int popts)
 Sets the specified set of processing options,.
static __inline unsigned int CCSDS_apidDscPopts (CCSDS_apidDsc *dsc)
 Returns the set of currently enabled processing options.
static __inline void CCSDS_apidDscPoptsSwapEnable (CCSDS_apidDsc *dsc)
 Convenience function to enabled the swapping processing option.
static __inline void CCSDS_apidDscPoptsSwapDisable (CCSDS_apidDsc *dsc)
 Convenience function to disabled the swapping processing option.


Detailed Description

CCSDS APID input stream descriptor (interface).

Author:
JJRussell - russell@slac.stanford.edu

   CVS $Id: CCSDS_apidDsc.h,v 1.5 2009/03/28 16:10:35 russell Exp $

Typedef Documentation

Typedef for enum _CCSDS_APIDDSC_BRIDGE_K.

The three basic styles are
  • Treat it as part of the payload
  • Treat it as part of a (secondary) header
  • Treat it as part of a (secondary) header and interpret it as the number of pad bytes

The first option is treating the packet like a plain vanilla CCSDS packet.
The second option is common, using this word like a bridge word. If this type is selected, then it is read and unpacked as part of the header, but no special meaning is ascribed to it.
The third option is to treat this word as the number of pad bytes. This is would be used, for example, to describe CCSDS packets from the SSR.

typedef int(* CCSDS_packetChecker)(void *ctx, void *stream, const CCSDS_telemetry *pkt, CCSDS_apidDsc *dsc)

This routine is callback immediately after a CCSDS packet has been read.

Returns:
Anything but 0 will stop the processing
Parameters:
ctx The checker's context parameter
stream The CCSDS stream handle, for example, if this was being called from CCSDS_istreamProcess, it would be CCSDS_istream
pkt The packet header
dsc The APID descriptor. This contains all the information about the current state of the packet plus the last read operation.
This routine can be used for two purposes. If provided, one responsibility is mandatory, it must check the integrity of the packet. This would usually include a call to CCSDS_istreamSivIsError to check the integrity of the IO operation and the basic packet integrity (mainly the sequencing). It could also include other APID specific tests.

int(* CCSDS_payloadProcessor)(void *ctx, const void *payload, int nbytes)

User callback routine to process the fully assembled payload of a sequence of CCSDS packets.

Return values:
== 0 Continue
!= 0 Stop
Parameters:
ctx Context parameter
payload The payload to process
nbytes The length, in bytes, of the payload


Enumeration Type Documentation

Enumerates how the odd 16-bit word, hereafter called the bridge word, that follows the normal 7 x 16-bit CCSDS header is to be treated.

Enumerator:
CCSDS_APIDDSC_BRIDGE_K_PAYLOAD  Plan old CCSDS packet
CCSDS_APIDDSC_BRIDGE_K_HEADER  Consider the orphaned 16-bit word as part of the secondary header, that is process it as part of the header reading
CCSDS_APIDDSC_BRIDGE_K_RSVD_2  Reserved for future use, illegal to specify
CCSDS_APIDDSC_BRIDGE_K_PAD  Consider the orphaned 16-bit word as part of the secondary header and interpret it as the number of pad bytes

Encapsulates known constants of the Apid Descriptor.

Enumerator:
CCSDS_APIDDSC_K_SEQ_RESET  The initial and reset value of the sequence number. This serves as a flag that there is no store context and so the sequence number of the next packet cannot be checked against the previous, because there is no previous one

Processing options, inplace masks.

Enumerator:
CCSDS_APIDDSC_POPTS_M_CHECKER  Enable packet checking routine
CCSDS_APIDDSC_POPTS_M_PROCESSOR  Enable payload processing
CCSDS_APIDDSC_POPTS_M_SWAP  Swap payload before processing

Processing options, right shifts.

Enumerator:
CCSDS_APIDDSC_POPTS_V_CHECKER  Enable packet checking
CCSDS_APIDDSC_POPTS_V_PROCESSOR  Enable payload processing
CCSDS_APIDDSC_POPTS_V_SWAP  Swap payload before processing


Function Documentation

void CCSDS_apidDscConstruct ( CCSDS_apidDsc dsc,
void *  ctx,
unsigned short int  apid,
CCSDS_APIDDSC_BRIDGE_K  bridge,
unsigned char *  buf,
unsigned int  buf_size 
)

Constructs (initializes) an CCSDS_apidDsc, an APID descriptor.

Parameters:
dsc The descriptor to construct/initialize
ctx User provided context parameter
apid The apid used as a key to identify this descriptor
bridge Dictates how the odd 16-bit word following the normal 7 x 16-bit word CCSDS header is to be treated.
buf A buffer to receive the data for this apid
buf_size The size, in bytes, of buf. This needs to be as large as the biggest CCSDS packet (including data that spans multiple packets).

References _CCSDS_apidDsc::apid, _CCSDS_apidDsc::bridge, _CCSDS_apidDsc::buf, CCSDS_APIDDSC_K_SEQ_RESET, CCSDS_istreamSivConstruct(), _CCSDS_apidDsc::ctx, _CCSDS_apidDsc::cur, _CCSDS_apidDsc::max, _CCSDS_apidDsc::seq, and _CCSDS_apidDsc::siv.

Referenced by CCSDS_apidDscRegister().

CCSDS_apidDsc* CCSDS_apidDscFind ( CCSDS_apidDscTbl tbl,
const CCSDS_header hdr 
)

Built-in method to locate the descriptor associated with the specified APID as read from the header.

Return values:
Non-NULL,the descriptor
NULL,error,either the descriptor with the specified APID does not exist or the APID cannot be gotten from the header because the header is unreadable (rare)
Parameters:
tbl The table to search
hdr The CCSDS header containing the APID to locate

References _CCSDS_apidDsc::apid, CCSDS__headerApid(), _CCSDS_apidDscNode::flnk, _CCSDS_apidDsc::node, and _CCSDS_apidDscTbl::que.

static __inline void CCSDS_apidDscPacketCheckerSet ( CCSDS_apidDsc dsc,
int  enb,
CCSDS_packetChecker  rtn,
void *  ctx 
) [static]

Establishes the packet checking routine. This routine is called to verify the integrity of a just read CCSDS packet.

Parameters:
dsc The target APID descriptor
enb If non-zero, enable checking. If this is zero, then the checking routine is established, but is not called. This is useful in some circumstances.
rtn The packet checking routine.
ctx A user provided context parameter to be passed to the packet checking routine.

References CCSDS_APIDDSC_POPTS_V_CHECKER, _CCSDS_apidHandlers::checker_ctx, _CCSDS_apidHandlers::checker_rtn, _CCSDS_apidDsc::handler, and _CCSDS_apidDsc::popts.

static __inline void CCSDS_apidDscPayloadProcessorSet ( CCSDS_apidDsc dsc,
int  enb,
CCSDS_payloadProcessor  rtn,
void *  ctx 
) [static]

Establishes the payload processing routine. This routine is called when the payload of all CCSDS packets have been assembled. Enabling the SWAP option will 32-bit swap the payload before handing it to the user.

Parameters:
dsc The target APID descriptor
enb If non-zero, enable checking. If this is zero, then the payload processing routine is established, but is not called. This is useful in some circumstances.
rtn The payload processing routine.
ctx A user provided context parameter to be passed to the payload processing routine.
Note:
The payload processing routine processes the fully assembled packet. While this fully assembled packet may be a datagram, there is no requirement that it must be a datagram. The CCDSS routines make no statement about the format of the assembled CCSDS packets.

References CCSDS_APIDDSC_POPTS_V_PROCESSOR, _CCSDS_apidDsc::handler, _CCSDS_apidDsc::popts, _CCSDS_apidHandlers::processor_ctx, and _CCSDS_apidHandlers::processor_rtn.

static __inline const void * CCSDS_apidDscPktBeg ( const CCSDS_apidDsc dsc  )  [static]

Returns a pointer to the beginning of the current LDF datagram.

Returns:
A pointer to the beginning of the current LDF datagram
Parameters:
dsc The APID descriptor

References _CCSDS_apidDsc::buf.

Referenced by CCSDS_istreamProcess().

static __inline const void * CCSDS_apidDscPktEnd ( const CCSDS_apidDsc dsc  )  [static]

Returns a pointer to the end (actually one bytes past the end) of the current LDF datagram.

Returns:
A pointer to the end of the current LDF datagram
Parameters:
dsc The APID descriptor

References _CCSDS_apidDsc::cur.

static __inline int CCSDS_apidDscPktLen ( const CCSDS_apidDsc dsc  )  [static]

Returns the length, in bytes, of the current LDF record.

Returns:
The length, in bytes, of the current LDF record
Parameters:
dsc The APID descriptor

References _CCSDS_apidDsc::buf, and _CCSDS_apidDsc::cur.

Referenced by CCSDS_istreamProcess().

static __inline unsigned int CCSDS_apidDscPopts ( CCSDS_apidDsc dsc  )  [static]

Returns the set of currently enabled processing options.

Returns:
The set of currently enabled processing options as an or of CCSDS_APIDDSC_POPTS_M values.
Parameters:
dsc The target APID descriptor

References _CCSDS_apidDsc::popts.

static __inline void CCSDS_apidDscPoptsDisable ( CCSDS_apidDsc dsc,
unsigned int  popts 
) [static]

Disables the specified set of processing options,.

See also:
CCSDS_APIDDSC_POPTS_M.
Parameters:
dsc The target APID descriptor
popts The list of processing options presented as an OR'd set of the CCSDS_APIDDSC_POPTS_M enumeration to disable.

References _CCSDS_apidDsc::popts.

static __inline void CCSDS_apidDscPoptsEnable ( CCSDS_apidDsc dsc,
unsigned int  popts 
) [static]

Enables the specified set of processing options,.

See also:
CCSDS_APIDDSC_POPTS_M.
Parameters:
dsc The target APID descriptor
popts The list of processing options presented as an OR'd set of the CCSDS_APIDDSC_POPTS_M enumeration to enable

References _CCSDS_apidDsc::popts.

static __inline void CCSDS_apidDscPoptsSet ( CCSDS_apidDsc dsc,
unsigned int  popts 
) [static]

Sets the specified set of processing options,.

See also:
CCSDS_APIDDSC_POPTS_M.
Parameters:
dsc The target APID descriptor
popts The list of processing options presented as an OR'd set of the CCSDS_APIDDSC_POPTS_M enumeration.

References _CCSDS_apidDsc::popts.

static __inline void CCSDS_apidDscPoptsSwapDisable ( CCSDS_apidDsc dsc  )  [static]

Convenience function to disabled the swapping processing option.

Parameters:
dsc The target APID descriptor
This strictly a convenience function. The same functionality could be accomplished using CCSDS_apidDscPoptsDisable with the processing option set to CCSDS_APIDDSC_POPTS_M_SWAP.

References CCSDS_APIDDSC_POPTS_M_SWAP, and _CCSDS_apidDsc::popts.

static __inline void CCSDS_apidDscPoptsSwapEnable ( CCSDS_apidDsc dsc  )  [static]

Convenience function to enabled the swapping processing option.

Parameters:
dsc The target APID descriptor
This strictly a convenience function. The same functionality could be accomplished using CCSDS_apidDscPoptsEnable with the processing option set to CCSDS_APIDDSC_POPTS_M_SWAP.

References CCSDS_APIDDSC_POPTS_M_SWAP, and _CCSDS_apidDsc::popts.

int CCSDS_apidDscRegister ( CCSDS_apidDscTbl tbl,
CCSDS_apidDsc dsc,
void *  ctx,
unsigned short int  apid,
CCSDS_APIDDSC_BRIDGE_K  bridge,
unsigned char *  buf,
unsigned int  buf_size 
)

Registers an APID descriptor.

Return values:
0,Successful 
-1,APID has been previously registered
Parameters:
tbl The apid table
dsc The descriptor to construct/initialize
ctx User provided context parameter
apid The apid used as a key to identify this descriptor
bridge Dictates how the odd 16-bit word following the normal 7 x 16-bit word CCSDS header is to be treated.
buf A buffer to receive the data for this apid
buf_size The size, in bytes, of buf. This needs to be as large as the biggest CCSDS packet (including data that spans multiple packets).

References CCSDS_apidDscConstruct(), insert(), _CCSDS_apidDsc::node, and _CCSDS_apidDscTbl::que.

void CCSDS_apidDscReset ( CCSDS_apidDsc dsc  ) 

Resets the specified APID descriptor to its initial state. This routine is used mainly for error recovery.

Parameters:
dsc The descriptor to reset

References _CCSDS_apidDsc::buf, CCSDS_APIDDSC_K_SEQ_RESET, CCSDS_istreamSivConstruct(), _CCSDS_apidDsc::cur, _CCSDS_apidDsc::seq, and _CCSDS_apidDsc::siv.

Referenced by CCSDS_istreamPktResynch().

static __inline void CCSDS_apidDscSeqReset ( CCSDS_apidDsc dsc  )  [static]

Resets the sequence number to indicate that the next packet encountered is the first. Since the sequence number of the first packet to be processed is unknown, this effectively disables the sequence checking.

Parameters:
dsc The APID descriptor

References _CCSDS_apidDsc::seq.

static __inline void CCSDS_apidDscSeqSet ( CCSDS_apidDsc dsc,
unsigned short int  seq 
) [static]

Sets the sequence number to the indicated value. This routine is only of interested when trying to resynch to a stream.

Parameters:
dsc The APID descriptor
seq The new sequence number. This should be only a maximum of 14 bits.

References _CCSDS_apidDsc::seq.

int CCSDS_apidDscSwap16 ( CCSDS_apidDsc dsc  ) 

Convenience routine to 16-bit swap all the words in the current buffer, presumed to be in a big-endian, to the local representation.

Returns:
The number of 16-bit words that where swapped
Parameters:
dsc The descriptor for the data to be swapped
Note:
On big-endian machine, except for the return value, this is a NOOP.

References _CCSDS_apidDsc::buf, _CCSDS_apidDsc::cur, and swap16bN().

int CCSDS_apidDscSwap32 ( CCSDS_apidDsc dsc  ) 

Convenience routine to 32-bit swap all the words in the current buffer, presumed to be in a big-endian, to the local representation.

Returns:
The number of 32-bit words that where swapped
Parameters:
dsc The descriptor for the data to be swapped
Note:
On big-endian machine, except for the return value, this is a NOOP.

References _CCSDS_apidDsc::buf, _CCSDS_apidDsc::cur, and swap32bN().

Referenced by CCSDS_istreamProcess().


Generated on Thu Sep 27 16:31:57 2012 by  doxygen 1.5.8