GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> QSD / dev > qsdccsds / sun-gcc


Interface   Data Structures   File List   Data Fields   Globals  

CCSDS_header.h File Reference

Layout of the CCSDS primary header. More...

#include <QSD/CCSDS_sequenceFlags.h>
#include <PBI/Endianness.h>
#include <netinet/in.h>

Classes

struct  _CCSDS_headerPid_bf
 The primary header's packet identifier word as bit fields. More...
union  _CCSDS_headerPid
 Union of the primary header's packet identifier word representation as a bit field and a uninterpretted 16-bit integer. More...
struct  _CCSDS_headerSeq_bf
 The CCSDS primary header sequence control word as bit fields. More...
union  _CCSDS_headerSeq
 Union of the primary header's sequence control word representation as a bit field and a uninterpretted 16-bit integer. More...
struct  _CCSDS_header
 Standard 6-byte CCSDS header. More...

Typedefs

typedef enum
_CCSDS_HEADER_VERSION_K 
CCSDS_HEADER_VERSION_K
 Typedef for _CCSDS_HEADER_VERSION_K.
typedef enum _CCSDS_HEADER_TYPE_K CCSDS_HEADER_TYPE_K
 Typedef for _CCSDS_HEADER_TYPE_K.
typedef struct _CCSDS_headerPid_bf CCSDS_headerPid_bf
 Typedef for struct _CCSDS_headerPid_bf.
typedef union _CCSDS_headerPid CCSDS_headerPid
 Typedef for union _CCSDS_headerPid.
typedef struct _CCSDS_headerSeq_bf CCSDS_headerSeq_bf
 Typedef for struct _CCSDS_headerSeq_bf.
typedef union _CCSDS_headerSeq CCSDS_headerSeq
 Typedef for union _CCSDS_headerSeq.
typedef struct _CCSDS_header CCSDS_header
typedef enum _CCSDS_VERIFY_ERR_V CCSDS_VERIFY_ERR_V
 Typedef for _CCSDS_VERIFY_ERR_V.
typedef enum _CCSDS_VERIFY_ERR_M CCSDS_VERIFY_ERR_M
 Typedef for _CCSDS_VERIFY_ERR_M.

Enumerations

enum  _CCSDS_HEADER_VERSION_K { CCSDS_HEADER_VERSION_K_1 = 0x0 }
 Enumeration of the current version. More...
enum  _CCSDS_HEADER_TYPE_K {
  CCSDS_HEADER_TYPE_K_TELEMETRY = 0,
  CCSDS_HEADER_TYPE_K_COMMAND = 1
}
 Enumeration of the packet types (telemetry and command). More...
enum  _CCSDS_VERIFY_ERR_V {
  CCSDS_VERIFY_ERR_V_VERSION = 0,
  CCSDS_VERIFY_ERR_V_TYPE = 1,
  CCSDS_VERIFY_ERR_V_SECONDARY = 2,
  CCSDS_VERIFY_ERR_V_FUNCTION = 3
}
 Enumeration of the verification error bits as right justified bit offsets. More...
enum  _CCSDS_VERIFY_ERR_M {
  CCSDS_VERIFY_ERR_M_VERSION = (1 << CCSDS_VERIFY_ERR_V_VERSION),
  CCSDS_VERIFY_ERR_M_TYPE = (1 << CCSDS_VERIFY_ERR_V_TYPE),
  CCSDS_VERIFY_ERR_M_SECONDARY = (1 << CCSDS_VERIFY_ERR_V_SECONDARY),
  CCSDS_VERIFY_ERR_M_FUNCTION = (1 << CCSDS_VERIFY_ERR_V_FUNCTION)
}
 Enumeration of the verification error bits as in place masks. More...

Functions

static __inline unsigned CCSDS__headerVersionIsWrong (const CCSDS_header *header)
 Checks if the CCSDS header format version matches the expectation.
static __inline unsigned CCSDS__headerApid (const CCSDS_header *header)
 Returns the application identifier.
static __inline unsigned CCSDS__headerSecondaryFlag (const CCSDS_header *header)
 Returns the value of the secondary header present flag.
static __inline unsigned CCSDS__headerType (const CCSDS_header *header)
 Returns the type of the packet.
static __inline unsigned CCSDS__headerVersion (const CCSDS_header *header)
 Returns the CCSDS header format version.
static __inline unsigned CCSDS__headerSequenceNumber (const CCSDS_header *header)
 Returns the packet sequence number.
static __inline unsigned CCSDS__headerSequenceFlags (const CCSDS_header *header)
 Returns the packet sequence flagnumber.
static __inline unsigned CCSDS__headerLength_m1 (const CCSDS_header *header)
 Returns the value of length_m1 field, in bytes.
static __inline void ccsds_bswp1_16 (void *buf, int nshorts)
 On little-endian machines, swaps the buffer to big-endian format.
static __inline void ccsds_bswp2_16 (void *dst, const void *src, int nshorts)
 On little-endian machines, swaps the buffer to big-endian format. On big-endian machines, this is a copy.


Detailed Description

Layout of the CCSDS primary header.

Author:
JJRussell - russell@slac.stanford.edu

   CVS $Id: CCSDS_header.h,v 1.5 2011/03/26 21:06:58 russell Exp $

Currently this package is laid out with a biase towards reading preexisting CCSDS packets, not writing new ones. Since this is a Q package, it is meant for ground-side only use, where reading is much more important than writing. In fact, if your particular programming goal is to debug a flight error, then, for the highest fidelity, one is compelled to use ground-side versions of the flight software. There may be other cases where one wishes to simulate flight behaviour (e.g. artificially compose a set of CCSDS packets) where it would be useful to be divorced from the flight software. The reoccurring use case here is that one discovers a problem that may or may not affect only the ground-side version of a flight routine. However, because of operational constraints the error cannot be fixed because the flight package is frozen. In this case, it would be useful to have a ground-only version of the code that is free of flight-code restrictions.
Philosophically, I (JJ) decided that this functionality all be presented in the include files, i.e. this package would not be presented in a shareable. For the most part, this is a reasonable decision. Most of the functionality is easily captured by the user either directly accessing the structures defining the CCSDS header and command and telemetry packets or through the use of trivial inlines. This breaks down a bit when computing the checksum for command packets, but I decided not to let this one routine drive what otherwise looks like a reasonable decision. This philosophy makes the user dependent one QSD only a compile-time, not at run-time and there are certainly advantages to that.
Usage
For the most part, except for the checksum routines and one other notable exception, the user is free to use the structure definitions directly. There are inline accessor routines which maybe notationally more convenient. They kind of flatten the hierarchial structures, freeing the user of remembering which structures various data fields reside in.
Notable exception
The notable exception to this is the length field. For good reasons, the CCSDS standard specifies that the length field represent the number of bytes in the CCSDS packet minus 1. So, if one directly accesses this field, that is the exactly what one gets; beware. However if one wishes the length of the user data (here called the payload), it may be more convenient to access this through the calls to CCSDS_commandLength or CCSDS_telemetryLength.
CCSDS Telemetry Length
A further word of caution on the telemetry length. Because the LAT's CCSDS packets are written via the LCB, they must be an integral number of 16-byte cells. Therefore, all telemetry packets are padded to 16 byte cells. Thus, the value returned by CCSDS_telemetryLength is always a multiple of 16 bytes. To get the the true length of the data, one needs to know how many pad bytes where inserted. Because the user data field starts on an odd 16-bit boundary and because it is convenient to consider the LAT user data as 32-bit words, it was decided to use this orphaned 16-bit word to carry the number of pad bytes. Depending on word semantics, this orphaned word can either be consider as
  • the first word of the user data
  • part of the secondary header.

Typedef Documentation

Typedef for _CCSDS_HEADER_VERSION_K.

This is a little overkill, but it gets the symbol into the debugger

Typedef for _CCSDS_VERIFY_ERR_M.

This maps out the bits of the status words returned by the verify routines.

Typedef for _CCSDS_VERIFY_ERR_V.

This maps out the bits of the status words returned by the verify routines.


Enumeration Type Documentation

Enumeration of the packet types (telemetry and command).

Enumerator:
CCSDS_HEADER_TYPE_K_TELEMETRY  Telemetry packet type
CCSDS_HEADER_TYPE_K_COMMAND  Command packet type

Enumeration of the current version.

Enumerator:
CCSDS_HEADER_VERSION_K_1  The expected version number is 0, but is referred to as Version 1, go figure

Enumeration of the verification error bits as in place masks.

Enumerator:
CCSDS_VERIFY_ERR_M_VERSION  Incorrect CCSDS version number
CCSDS_VERIFY_ERR_M_TYPE  Incorrect packet type, e.g. command packet when expecting a telemetry packet
CCSDS_VERIFY_ERR_M_SECONDARY  Incorrect secondary header state, e.g. no secondary header when expecting one
CCSDS_VERIFY_ERR_M_FUNCTION  Illegal function code, this is meaningful only for command packets. On GLAST, the function codes are limited to 15 bits. This bit gets set if the upper bit of the 16-bit function code is set

Enumeration of the verification error bits as right justified bit offsets.

Enumerator:
CCSDS_VERIFY_ERR_V_VERSION  Incorrect CCSDS version number
CCSDS_VERIFY_ERR_V_TYPE  Incorrect packet type, e.g. command packet when expecting a telemetry packet
CCSDS_VERIFY_ERR_V_SECONDARY  Incorrect secondary header state, e.g. no secondary header when expecting one
CCSDS_VERIFY_ERR_V_FUNCTION  Illegal function code, this is meaningful only for command packets. On GLAST, the function codes are limited to 15 bits. This bit gets set if the upper bit of the 16-bit function code is set


Function Documentation

static __inline unsigned CCSDS__headerApid ( const CCSDS_header header  )  [static]

Returns the application identifier.

Returns:
The APID
Parameters:
header The packet header

References _CCSDS_headerPid::bf, and _CCSDS_header::pid.

Referenced by CCSDS_apidDscFind().

static __inline unsigned CCSDS__headerLength_m1 ( const CCSDS_header header  )  [static]

Returns the value of length_m1 field, in bytes.

Returns:
The value of length field, in bytes
Parameters:
header The packet header
Warning:
This is the raw value of the length field in the CCSDS packet. It is the size, in bytes of any secondary header + the payload - 1. If one wishes the size of just the command or telemetry payloads, use CCSDS__packetCommandLength and CCSDS__packetTelemetryLength.

References _CCSDS_header::length_m1.

static __inline unsigned CCSDS__headerSecondaryFlag ( const CCSDS_header header  )  [static]

Returns the value of the secondary header present flag.

Return values:
==0,if a secondary header is not present
!=0,if a secondary header is present
Parameters:
header The packet header

References _CCSDS_headerPid::bf, and _CCSDS_header::pid.

static __inline unsigned CCSDS__headerSequenceFlags ( const CCSDS_header header  )  [static]

Returns the packet sequence flagnumber.

Return values:
0 (00b) If the packet contains a continuation segment of user data
1 (01b) If the packet contains the first segment of user data
2 (10b) If the packet contains the last segment of user data
3 (11b) If the packet contains unsegmented user data
Parameters:
header The packet header

References _CCSDS_headerSeq::bf, and _CCSDS_header::seq.

static __inline unsigned CCSDS__headerSequenceNumber ( const CCSDS_header header  )  [static]

Returns the packet sequence number.

Returns:
The packet sequence number
Parameters:
header The packet header

References _CCSDS_headerSeq::bf, and _CCSDS_header::seq.

static __inline unsigned CCSDS__headerType ( const CCSDS_header header  )  [static]

Returns the type of the packet.

Return values:
==0,if the packet is a telemetry packet
!=0,if the packet is a command packet
Parameters:
header The packet header

References _CCSDS_headerPid::bf, and _CCSDS_header::pid.

static __inline unsigned CCSDS__headerVersion ( const CCSDS_header header  )  [static]

Returns the CCSDS header format version.

Returns:
The CCSDS header format version
Parameters:
header The packet header

References _CCSDS_headerPid::bf, and _CCSDS_header::pid.

static __inline unsigned CCSDS__headerVersionIsWrong ( const CCSDS_header header  )  [static]

Checks if the CCSDS header format version matches the expectation.

Return values:
==0 if it does
!=0 if it does not (actually the difference expected - actual
Parameters:
header The packet header

References _CCSDS_headerPid::bf, CCSDS_HEADER_VERSION_K_1, and _CCSDS_header::pid.

static __inline void ccsds_bswp1_16 ( void *  buf,
int  nshorts 
) [static]

On little-endian machines, swaps the buffer to big-endian format.

On big-endian machines, this is a NOOP

Parameters:
buf The buffer to swap
nshorts The number of 16-bit words to swap

Referenced by CCSDS__telemetrySsrSwapb(), and CCSDS__telemetrySwapb().

static __inline const ccsds_bswp2_16 ( void *  dst,
const void *  src,
int  nshorts 
) [static]

On little-endian machines, swaps the buffer to big-endian format. On big-endian machines, this is a copy.

Parameters:
dst The destination buffer
src The source buffer
nshorts The number of 16-bit words to swap

Referenced by CCSDS__telemetrySsrSwap2b(), and CCSDS__telemetrySwap2b().


Generated on Fri Sep 21 11:42:18 2012 by  doxygen 1.5.8