GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> CCSDS / V3-5-3 > ccsds_pkt / mv2304
#include <CCSDS/CCSDS_msg.h>
Typedefs | |
typedef enum _CCSDS_Pkt_Version | CCSDS_Pkt_Version |
typedef enum _CCSDS_Pkt_Type | CCSDS_Pkt_Type |
typedef enum _CCSDS_Pkt_Sec_Hdr_Flag | CCSDS_Pkt_Sec_Hdr_Flag |
typedef enum _CCSDS_Pkt_Seq_Flags | CCSDS_Pkt_Seq_Flags |
Enumerations | |
enum | _CCSDS_Pkt_Version { CCSDS_PKT_VERSION_1 = 0x0000 } |
enum | _CCSDS_Pkt_Type { CCSDS_PKT_TYPE_TELEM = 0x0000, CCSDS_PKT_TYPE_CMD = 0x1000 } |
enum | _CCSDS_Pkt_Sec_Hdr_Flag { CCSDS_PKT_SEC_HDR_FALSE = 0x0000, CCSDS_PKT_SEC_HDR_TRUE = 0x0800 } |
enum | _CCSDS_Pkt_Seq_Flags { CCSDS_PKT_SEQ_MID = 0x0000, CCSDS_PKT_SEQ_FIRST = 0x4000, CCSDS_PKT_SEQ_LAST = 0x8000, CCSDS_PKT_SEQ_NONE = 0xc000 } |
Functions | |
Packet Header Functions | |
unsigned int | CCSDS_pktHdrCreate (void *pkt, CCSDS_Pkt_Type type, unsigned short apid, CCSDS_Pkt_Seq_Flags seqFlags, unsigned short seqCount, unsigned short length, unsigned int secs, unsigned int fc_ss) |
Create a CCSDS packet header. | |
unsigned int | CCSDS_pktHdrSizeof (CCSDS_Pkt_Type type) |
Get the size of a CCSDS packet header. | |
unsigned int | CCSDS_pktHdrVerify (const void *pkt) |
Verify the prescience of a valid CCSDS packet header. | |
unsigned int | CCSDS_pktHdrSetApid (void *pkt, unsigned short apid) |
Set the application ID value in a CCSDS packet header. | |
unsigned int | CCSDS_pktHdrSetLength (void *pkt, unsigned short length) |
Set the packet length value in a CCSDS packet header. | |
unsigned int | CCSDS_pktHdrSetSeqCount (void *pkt, unsigned short seqCount) |
Set the sequence count value in a CCSDS packet header. | |
unsigned int | CCSDS_pktHdrSetSeqFlags (void *pkt, CCSDS_Pkt_Seq_Flags seqFlags) |
Set the sequence flags value in a CCSDS packet header. | |
unsigned int | CCSDS_pktHdrSetTime (void *pkt, unsigned int sec, unsigned int subSec) |
Set the timestamp value in a CCSDS telemetry packet header. | |
unsigned int | CCSDS_pktHdrSetFuncCode (void *pkt, unsigned short funcCode) |
Set the function code value in a CCSDS command packet header. | |
unsigned int | CCSDS_pktHdrGetLength (const void *pkt, unsigned short *length) |
Get the packet length value in a CCSDS packet header. | |
unsigned int | CCSDS_pktHdrGetType (const void *pkt, unsigned short *type) |
Get the packet type value in a CCSDS packet header. | |
unsigned int | CCSDS_pktHdrGetApid (const void *pkt, unsigned short *apid) |
Get the application ID value in a CCSDS packet header. | |
unsigned int | CCSDS_pktHdrGetSeqCount (const void *pkt, unsigned short *seqCount) |
Get the packet sequence count value in a CCSDS packet header. | |
unsigned int | CCSDS_pktHdrGetSeqFlags (const void *pkt, unsigned short *seqFlags) |
Get the packet grouping value in a CCSDS packet header. | |
unsigned int | CCSDS_pktHdrGetTime (const void *pkt, unsigned int *sec, unsigned int *subSec) |
Get the timestamp value in a CCSDS telemetry packet header. | |
unsigned int | CCSDS_pktHdrGetFuncCode (const void *pkt, unsigned short *funcCode) |
Get the function code value in a CCSDS command packet header. | |
Packet Checksum Functions | |
unsigned short | CCSDS_pktChksumCalc (const void *pkt, int size) |
Calculate a packet checksum value. | |
unsigned int | CCSDS_pktChksumInsert (void *pkt, int size) |
Calculate and insert a packet checksum. | |
unsigned int | CCSDS_pktChksumVerify (const void *pkt, int size) |
Verify a packet checksum value. | |
unsigned int | CCSDS_pktChksumSizeof (void) |
Get the size of a CCSDS telecommand packet checksum. |
This library contains functions and definitions for manipulating and examining the values in the GLAST LAT CCSDS Version 1 Packet headers. The functions will work with both Telecommand Packets (uplink and SC command) and Telemetry Source Packets (downlink).
The specifications for the CCSDS Packet header formats may be found in the following documents:
Telecommand - CCSDS Telecommand Part 3 (203.0-B-1 Blue Book)
Telemetry - CCSDS Packet Telemetry (102.0-B-5 Blue Book)
Time Formats - CCSDS Time Code Formats (301.0-B-2 Blue Book)
GLAST Specific Formats - GLAST LAT - SC Interface Control Document
CCSDS Packet Library User Manual
There is a function CCSDS_pktHdrCreate(), which will create a new packet header in user memory from scratch. All header member values must be specified. For each of the header members, the function CCSDS_pktHdrGetXXX() and CCSDS_pktHdrSetXXX() will selectively retrive or alter an existing CCSDS packet header in user memory. The packet checksum functions are primarily intented for telecommand packets, and implement the checksum algoritm detailed in the SC-LAT ICD.
The typedef for _CCSDS_Pkt_Sec_Hdr_Flag.
The typedef for _CCSDS_Pkt_Seq_Flags
The typedef for _CCSDS_Pkt_Type.
The typedef for _CCSDS_Pkt_Version.
CCSDS packet secondary header flag. The functions in this library support using either a 6 byte telemetry secondary header or a 2 byte telecommand secondary header.
enum _CCSDS_Pkt_Seq_Flags |
enum _CCSDS_Pkt_Type |
enum _CCSDS_Pkt_Version |
CCSDS packet version number. Only CCSDS_PKT_VERSION_1 specifics are supported by the library functions.
unsigned short CCSDS_pktChksumCalc | ( | const void * | pkt, | |
int | size | |||
) |
Calculate a packet checksum value.
Calculates the value of a packet checksum over a range of packet data. The algorithm is:
pkt | A pointer to the beginning of the range to checksum. | |
size | The number of bytes to checksum. |
Referenced by CCSDS_pktChksumInsert(), and CCSDS_pktChksumVerify().
unsigned int CCSDS_pktChksumInsert | ( | void * | pkt, | |
int | size | |||
) |
Calculate and insert a packet checksum.
Calculates the value of a packet checksum over a range of packet data. The checksum value is inserted at the proper location at the end of the packet application data.
pkt | A pointer to the beginning of the range to checksum (packet header). | |
size | The total number of bytes in the packet including packet header and checksum slot. |
References CCSDS_PKT_MSG, CCSDS_pktChksumCalc(), and NULL.
unsigned int CCSDS_pktChksumSizeof | ( | void | ) |
Get the size of a CCSDS telecommand packet checksum.
Returns the size in bytes of a CCSDS telecommand packet checksum word.
References CCSDS_PKT_CHKSUM_SIZE.
unsigned int CCSDS_pktChksumVerify | ( | const void * | pkt, | |
int | size | |||
) |
Verify a packet checksum value.
Calculates the value of a packet checksum over a range of packet data. The checksum value is compared to the value stored at the end of the packet application data.
pkt | A pointer to the beginning of the range to checksum (packet header). | |
size | The total number of bytes in the packet including packet header and checksum slot. |
References CCSDS_PKT_MSG, CCSDS_pktChksumCalc(), and NULL.
unsigned int CCSDS_pktHdrCreate | ( | void * | pkt, | |
CCSDS_Pkt_Type | type, | |||
unsigned short | apid, | |||
CCSDS_Pkt_Seq_Flags | seqFlags, | |||
unsigned short | seqCount, | |||
unsigned short | length, | |||
unsigned int | secs, | |||
unsigned int | fc_ss | |||
) |
Create a CCSDS packet header.
Creates a CCSDS packet header in the buffer specified by pkt. The user is resposible for filling in the application data immediately after the start of the packet header. This library only supports packets whose total size is aligned on a 16-bit boundary. The function will fail with an error if the length parameter is not correctly aligned or is too large for the 64 KB limit on packets.
pkt | A pointer to the packet header buffer. | |
type | The packet type. | |
apid | The application ID value of the packet. | |
seqFlags | The packet grouping flags. | |
seqCount | The sequence counter for this application ID. | |
length | The length in bytes of the application data to follow the packet header. | |
secs | The time seconds counter value to place in the packet timestamp. This value is ignored if type is CCSDS_PKT_TYPE_CMD. | |
fc_ss | If type is CCSDS_PKT_TYPE_CMD, this is the value of the function code (limit 32767). If type is CCSDS_PKT_TYPE_TELEM, this is the value of the time sub-subseconds counter (limit 999,999). |
References CCSDS_ID_APID_MASK, CCSDS_ID_TYPE_MASK, CCSDS_PKT_CMD_SEC_SIZE, CCSDS_PKT_MAX_CMD_SIZE, CCSDS_PKT_MAX_TELEM_SIZE, CCSDS_PKT_MSG, CCSDS_PKT_SEC_HDR_TRUE, CCSDS_PKT_TELEM_SEC_SIZE, CCSDS_PKT_TYPE_CMD, CCSDS_PKT_TYPE_TELEM, CCSDS_PKT_VERSION_1, CCSDS_SEC_FUNC_CODE_MASK, CCSDS_SEC_SSEC_MAX, CCSDS_SEQ_COUNT_MASK, CCSDS_SEQ_FLAGS_MASK, _CCSDS_Pkt_Hdr_Cmd::hdr_func, _CCSDS_Pkt_Hdr_Pri::hdr_id, _CCSDS_Pkt_Hdr_Pri::hdr_length, _CCSDS_Pkt_Hdr_Telem::hdr_sec_lsw, _CCSDS_Pkt_Hdr_Telem::hdr_sec_msw, _CCSDS_Pkt_Hdr_Pri::hdr_seq, _CCSDS_Pkt_Hdr_Telem::hdr_ssec_lsw, _CCSDS_Pkt_Hdr_Telem::hdr_ssec_msw, and NULL.
unsigned int CCSDS_pktHdrGetApid | ( | const void * | pkt, | |
unsigned short * | apid | |||
) |
Get the application ID value in a CCSDS packet header.
Returns the CCSDS packet application ID.
pkt | A pointer to the start of the packet buffer. | |
apid | Stores the application ID value. |
References CCSDS_ID_APID_MASK, CCSDS_PKT_MSG, _CCSDS_Pkt_Hdr_Pri::hdr_id, and NULL.
unsigned int CCSDS_pktHdrGetFuncCode | ( | const void * | pkt, | |
unsigned short * | funcCode | |||
) |
Get the function code value in a CCSDS command packet header.
Returns the value of a CCSDS command packet header function code.
pkt | A pointer to the start of the packet buffer. | |
funcCode | Stores the function code value. |
References CCSDS_ID_TYPE_MASK, CCSDS_PKT_MSG, CCSDS_PKT_TYPE_TELEM, CCSDS_SEC_FUNC_CODE_MASK, _CCSDS_Pkt_Hdr_Cmd::hdr_func, _CCSDS_Pkt_Hdr_Cmd::hdr_id, and NULL.
unsigned int CCSDS_pktHdrGetLength | ( | const void * | pkt, | |
unsigned short * | length | |||
) |
Get the packet length value in a CCSDS packet header.
Returns the value of the CCSDS packet header length member. The size of the packet header is taken into account when extracting the actual packet header length member, so that the return value from this function only represents the size of application data following the packet header.
pkt | A pointer to the start of the packet buffer. | |
length | Stores the length in bytes of the user application data to following the packet header. |
References CCSDS_ID_TYPE_MASK, CCSDS_PKT_CMD_SEC_SIZE, CCSDS_PKT_MSG, CCSDS_PKT_TELEM_SEC_SIZE, CCSDS_PKT_TYPE_TELEM, _CCSDS_Pkt_Hdr_Pri::hdr_id, _CCSDS_Pkt_Hdr_Pri::hdr_length, and NULL.
unsigned int CCSDS_pktHdrGetSeqCount | ( | const void * | pkt, | |
unsigned short * | seqCount | |||
) |
Get the packet sequence count value in a CCSDS packet header.
Returns the CCSDS packet sequence count.
pkt | A pointer to the start of the packet buffer. | |
seqCount | Stores the sequence count value. |
References CCSDS_PKT_MSG, CCSDS_SEQ_COUNT_MASK, _CCSDS_Pkt_Hdr_Pri::hdr_seq, and NULL.
unsigned int CCSDS_pktHdrGetSeqFlags | ( | const void * | pkt, | |
unsigned short * | seqFlags | |||
) |
Get the packet grouping value in a CCSDS packet header.
Returns the CCSDS packet sequence flags.
pkt | A pointer to the start of the packet buffer. | |
seqFlags | Stores the sequence flags value: CCSDS_PKT_SEQ_FIRST The packet is the first packet in a group. CCSDS_PKT_SEQ_MID The packet is an intermediate packet in a group. CCSDS_PKT_SEQ_LAST The packet is the last packet in a group. CCSDS_PKT_SEQ_NONE The packet is standalone and not part of a group. |
References CCSDS_PKT_MSG, CCSDS_SEQ_FLAGS_MASK, _CCSDS_Pkt_Hdr_Pri::hdr_seq, and NULL.
unsigned int CCSDS_pktHdrGetTime | ( | const void * | pkt, | |
unsigned int * | sec, | |||
unsigned int * | subSec | |||
) |
Get the timestamp value in a CCSDS telemetry packet header.
Returns the value of the CCSDS telemetry packet header timestamp counters. This function always returns an error if the packet is a command packet.
pkt | A pointer to the start of the packet buffer. | |
sec | Stores the timestamp seconds counter value. | |
subSec | Stores the timestamp sub-seconds counter value |
References CCSDS_ID_TYPE_MASK, CCSDS_PKT_MSG, CCSDS_PKT_TYPE_CMD, _CCSDS_Pkt_Hdr_Telem::hdr_id, _CCSDS_Pkt_Hdr_Telem::hdr_sec_lsw, _CCSDS_Pkt_Hdr_Telem::hdr_sec_msw, _CCSDS_Pkt_Hdr_Telem::hdr_ssec_lsw, _CCSDS_Pkt_Hdr_Telem::hdr_ssec_msw, and NULL.
unsigned int CCSDS_pktHdrGetType | ( | const void * | pkt, | |
unsigned short * | type | |||
) |
Get the packet type value in a CCSDS packet header.
Returns the CCSDS packet header type.
pkt | A pointer to the start of the packet buffer. | |
type | Stores the packet type: CCSDS_PKT_TYPE_CMD The packet is a Telecommand packet. CCSDS_PKT_TYPE_TELEM The packet is a Telemetry Source packet. |
References CCSDS_ID_TYPE_MASK, CCSDS_PKT_MSG, _CCSDS_Pkt_Hdr_Pri::hdr_id, and NULL.
unsigned int CCSDS_pktHdrSetApid | ( | void * | pkt, | |
unsigned short | apid | |||
) |
Set the application ID value in a CCSDS packet header.
Assigns the value of the CCSDS packet header application ID member.
pkt | A pointer to the start of the packet buffer. | |
apid | The application ID value. |
References CCSDS_ID_APID_MASK, CCSDS_PKT_MSG, _CCSDS_Pkt_Hdr_Pri::hdr_id, and NULL.
unsigned int CCSDS_pktHdrSetFuncCode | ( | void * | pkt, | |
unsigned short | funcCode | |||
) |
Set the function code value in a CCSDS command packet header.
Assigns the value of a CCSDS command packet header function code. This function always returns an error if the packet is a telemetry packet.
pkt | A pointer to the start of the packet buffer. | |
funcCode | The function code value to assign (limit 32,767) |
References CCSDS_ID_TYPE_MASK, CCSDS_PKT_MSG, CCSDS_PKT_TYPE_TELEM, CCSDS_SEC_FUNC_CODE_MASK, _CCSDS_Pkt_Hdr_Cmd::hdr_func, _CCSDS_Pkt_Hdr_Cmd::hdr_id, and NULL.
unsigned int CCSDS_pktHdrSetLength | ( | void * | pkt, | |
unsigned short | length | |||
) |
Set the packet length value in a CCSDS packet header.
Assigns the value of the CCSDS packet header length member. The length parameter should give the size in bytes of the application data to follow the packet header. This function will account for the header size when assigning the actual packet header length member. This library only supports packets whose total size is aligned on a 16-bit boundary. The function will fail with an error if the length parameter is not correctly aligned or is too large for the 64 KB limit on packets.
pkt | A pointer to the start of the packet buffer. | |
length | The length in bytes of the user application data to follow the packet header. Command packets are not allowed to be empty. |
References CCSDS_ID_TYPE_MASK, CCSDS_PKT_CMD_SEC_SIZE, CCSDS_PKT_MAX_CMD_SIZE, CCSDS_PKT_MAX_TELEM_SIZE, CCSDS_PKT_MSG, CCSDS_PKT_TELEM_SEC_SIZE, CCSDS_PKT_TYPE_CMD, CCSDS_PKT_TYPE_TELEM, _CCSDS_Pkt_Hdr_Pri::hdr_id, _CCSDS_Pkt_Hdr_Pri::hdr_length, and NULL.
unsigned int CCSDS_pktHdrSetSeqCount | ( | void * | pkt, | |
unsigned short | seqCount | |||
) |
Set the sequence count value in a CCSDS packet header.
Assigns the value of the CCSDS packet header sequence count member.
pkt | A pointer to the start of the packet buffer. | |
seqCount | The sequence counter. |
References CCSDS_PKT_MSG, CCSDS_SEQ_COUNT_MASK, _CCSDS_Pkt_Hdr_Pri::hdr_seq, and NULL.
unsigned int CCSDS_pktHdrSetSeqFlags | ( | void * | pkt, | |
CCSDS_Pkt_Seq_Flags | seqFlags | |||
) |
Set the sequence flags value in a CCSDS packet header.
Assigns the value of the CCSDS packet header sequence flags member.
pkt | A pointer to the start of the telemetry packet buffer. | |
seqFlags | The sequence flags (one of the CCSDS_Pkt_Seq_Flags values). |
References CCSDS_PKT_MSG, CCSDS_SEQ_FLAGS_MASK, _CCSDS_Pkt_Hdr_Pri::hdr_seq, and NULL.
unsigned int CCSDS_pktHdrSetTime | ( | void * | pkt, | |
unsigned int | sec, | |||
unsigned int | subSec | |||
) |
Set the timestamp value in a CCSDS telemetry packet header.
Assigns the value of a CCSDS telemetry packet header timestamp. This function always returns an error if the packet is a command packet.
pkt | A pointer to the start of the packet buffer. | |
sec | The timestamp seconds counter value. | |
subSec | The timestamp sub-seconds counter value (limit 999,999). |
References CCSDS_ID_TYPE_MASK, CCSDS_PKT_MSG, CCSDS_PKT_TYPE_CMD, CCSDS_SEC_SSEC_MAX, _CCSDS_Pkt_Hdr_Telem::hdr_id, _CCSDS_Pkt_Hdr_Telem::hdr_sec_lsw, _CCSDS_Pkt_Hdr_Telem::hdr_sec_msw, _CCSDS_Pkt_Hdr_Telem::hdr_ssec_lsw, _CCSDS_Pkt_Hdr_Telem::hdr_ssec_msw, and NULL.
unsigned int CCSDS_pktHdrSizeof | ( | CCSDS_Pkt_Type | type | ) |
Get the size of a CCSDS packet header.
Returns the combined size of the CCSDS packet primary and secondary headers. This value must be taken into account when creating a packet buffer in memory or when sending the entire packet (header + application data).
type | The packet type. |
References CCSDS_ID_TYPE_MASK, CCSDS_PKT_CMD_HDR_SIZE, CCSDS_PKT_TELEM_HDR_SIZE, and CCSDS_PKT_TYPE_TELEM.
unsigned int CCSDS_pktHdrVerify | ( | const void * | pkt | ) |
Verify the prescience of a valid CCSDS packet header.
Checks to see if the contents of pkt contain a properly formatted CCSDS packet header.
pkt | A pointer to the start of the packet buffer. |
References CCSDS_ID_SEC_HDR_MASK, CCSDS_ID_TYPE_MASK, CCSDS_ID_VERSION_MASK, CCSDS_PKT_MSG, CCSDS_PKT_SEC_HDR_TRUE, CCSDS_PKT_TYPE_CMD, CCSDS_PKT_VERSION_1, CCSDS_SEC_TYPE_MASK, _CCSDS_Pkt_Hdr_Cmd::hdr_func, _CCSDS_Pkt_Hdr_Pri::hdr_id, and NULL.