GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > QSD / V0-3-0

Constituent: qsd_print     Tag: sun-gcc


Interface   Data Structures   File List   Data Fields   Globals  

CCSDS_header.h File Reference

Layout of the CCSDS primary header. More...

#include "PBI/Endianness.h"
#include <netinet/in.h>

Include dependency graph for CCSDS_header.h:

This graph shows which files directly or indirectly include this file:


Data Structures

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 _CCSDS_headerPid_bf CCSDS_headerPid_bf
 Typedef for struct _CCSDS_headerPid_bf.
typedef _CCSDS_headerPid CCSDS_headerPid
 Typedef for union _CCSDS_headerPid.
typedef enum _CCSDS_SEQUENCE_FLAGS_M CCSDS_SEQUENCE_FLAGS_M
 Typedef for enum _CCSDS_SEQUENCE_FLAGS_M.
typedef enum _CCSDS_SEQUENCE_FLAGS_K CCSDS_SEQUENCE_FLAGS_K
 Typedef for CCSDS_SEQUENCE_FLAGS_K.
typedef _CCSDS_headerSeq_bf CCSDS_headerSeq_bf
 Typedef for struct _CCSDS_headerSeq_bf.
typedef _CCSDS_headerSeq CCSDS_headerSeq
 Typedef for union _CCSDS_headerSeq.
typedef _CCSDS_header CCSDS_header
 Typedef for struct _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_SEQUENCE_FLAGS_M {
  CCSDS_SEQUENCE_FLAGS_M_FIRST = 1 << 0,
  CCSDS_SEQUENCE_FLAGS_M_LAST = 1 << 1
}
 The CCSDS sequence flags. This is really a 2 bit a value with bit 0 indicating whether this is the first CCSDS packet and bit 1 indicating whether this is the last CCSDS packet. More...
enum  _CCSDS_SEQUENCE_FLAGS_K {
  CCSDS_SEQUENCE_FLAGS_K_MIDDLE = 0,
  CCSDS_SEQUENCE_FLAGS_K_FIRST = CCSDS_SEQUENCE_FLAGS_M_FIRST,
  CCSDS_SEQUENCE_FLAGS_K_LAST = CCSDS_SEQUENCE_FLAGS_M_LAST,
  CCSDS_SEQUENCE_FLAGS_K_ONLY
}
 Enumerates the state value represented by the sequence flags. 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 const void ccsds_bswp1_16 (void *buf, int nshorts)
 On little-endian machines, swaps the buffer to big-endian format. On big-endian machines, this is a NOOP.
static __inline const 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.3 2008/04/04 21:22:35 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

Typedef Documentation

CCSDS_HEADER_VERSION_K
 

Typedef for _CCSDS_HEADER_VERSION_K.

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

CCSDS_SEQUENCE_FLAGS_K
 

Typedef for CCSDS_SEQUENCE_FLAGS_K.

While the sequence flags are formally defined as two separate 1-bit fields, a bit indicating whether this is the first packet in (potentially) a sequence and a bit indicating whether this is the last bit in (potentially) a sequence, it is sometimes convenient to view the combination as defining a value 0-3 and naming the values
  • 00 (0) Neither the first nor last packet in a sequence, therefore a middle packet
  • 01 (1) The first packet in a sequence
  • 10 (2) The last packet in a sequence
  • 11 (3) Both the first and last packet, therefore the only packet

CCSDS_VERIFY_ERR_M
 

Typedef for _CCSDS_VERIFY_ERR_M.

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

CCSDS_VERIFY_ERR_V
 

Typedef for _CCSDS_VERIFY_ERR_V.

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


Enumeration Type Documentation

enum _CCSDS_HEADER_TYPE_K
 

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

enum _CCSDS_HEADER_VERSION_K
 

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

enum _CCSDS_SEQUENCE_FLAGS_K
 

Enumerates the state value represented by the sequence flags.

Enumerator:
CCSDS_SEQUENCE_FLAGS_K_MIDDLE  This is a middle packet in a sequence of packets
CCSDS_SEQUENCE_FLAGS_K_FIRST  This is the first packet in a sequence of packets
CCSDS_SEQUENCE_FLAGS_K_LAST  This is the last packet in a sequence of packets
CCSDS_SEQUENCE_FLAGS_K_ONLY  This is the only packet, i.e. not a sequence (literally this is both the first and last packet

enum _CCSDS_SEQUENCE_FLAGS_M
 

The CCSDS sequence flags. This is really a 2 bit a value with bit 0 indicating whether this is the first CCSDS packet and bit 1 indicating whether this is the last CCSDS packet.

Enumerator:
CCSDS_SEQUENCE_FLAGS_M_FIRST  The packet is the first
CCSDS_SEQUENCE_FLAGS_M_LAST  The packet is the last

enum _CCSDS_VERIFY_ERR_M
 

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

enum _CCSDS_VERIFY_ERR_V
 

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

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.

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

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

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

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

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

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

static __inline const 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

static __inline const void 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


Generated on Sat Sep 20 02:29:08 2008 by  doxygen 1.4.4