GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> SIIS / V0-2-0 > siis2moc / sun-gcc
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "CCSDS/CCSDS_pkt.h"
#include "CCSDS/CCSDS_pri.h"
#include "MSG/MSG_pubdefs.h"
#include "MSG/MSG_printProc.h"
#include "PBS/TASK.h"
#include "SIIS/SIIS_file.h"
#include "SIIS/SIIS_moc.h"
#include "SIIS/SIIS_rec.h"
#include "SIIS/SIIS_vcdu.h"
Classes | |
| struct | _Apid_Info |
Defines | |
| #define | GLAST_ID 251 |
| #define | DIM(a) (sizeof (a) / sizeof (*a)) |
Typedefs | |
| typedef struct _Apid_Info | Apid_Info |
Functions | |
| static unsigned int | find_apid_entry (Apid_Info **apid_info_p, const unsigned short apid, const unsigned short vcid) |
| static unsigned int | add_apid_entry (Apid_Info **apid_info_p, const unsigned short apid, const unsigned short vcid) |
| static unsigned int | parse_command_line (int argc, char *argv[]) |
| Interpret the command line parameters. | |
| void | print_message (MSG_OutputModes mode, void *prm, const MSG_Message *msg) |
| Output processor callback routine to print messages. | |
| static unsigned int | start_message_system (void) |
| static unsigned int | stop_message_system (void) |
| static unsigned int | skip_file_data (FILE *in_file, const unsigned int num_bytes) |
| static unsigned int | create_moc_file (Apid_Info *apid_info, const SIIS_Pdu_Hdr *pdu_hdr) |
| static unsigned int | get_apid_info (Apid_Info **apid_info_p, const SIIS_Pdu_Hdr *pdu_hdr, const unsigned short apid) |
| static unsigned int | close_moc_files (void) |
| static unsigned int | gather_pdu_header (SIIS_Pdu_Hdr *pdu_hdr, const unsigned int vcdu_status, const unsigned int time_tag, const SIIS_Vcdu_Hdr *vcdu_hdr) |
| static unsigned int | parse_ccsds_header (const unsigned char *data, const unsigned int data_bytes, unsigned short *type, unsigned short *apid, unsigned short *length) |
| static unsigned int | write_ccsds_packet (SIIS_Pdu_Hdr *pdu_hdr, const unsigned char *data, const unsigned int data_bytes, const unsigned short apid, const unsigned short length) |
| static unsigned int | extract_ccsds_packets (SIIS_Pdu_Hdr *pdu_hdr, const unsigned char *data, unsigned int data_bytes) |
| static unsigned int | process_raw_telem (const unsigned char *body, const unsigned int body_bytes, const unsigned int time_tag) |
| unsigned int | process_record (FILE *in_file) |
| int | main (int argc, char *argv[]) |
Variables | |
| static char * | In_File_Name |
| Pointer to the name of the input file. | |
| static int | Include_All |
| Indicates whether we're including all APIDs. | |
| static int | Frame_Count = 0 |
| Number of VCDU frames processed. | |
| static int | Packet_Read_Count = 0 |
| Number of CCSDS packets read. | |
| static int | Packet_Write_Count = 0 |
| Number of CCSDS packets written. | |
| static int | Apid_Count = 0 |
| Number of different APIDs found. | |
| static Apid_Info | Apid_Vcid [32] = { { 0 } } |
| Table of APID/VCIDs found in the archive file. | |
CVS $Id: siis2moc.c,v 1.3 2004/12/02 17:52:51 dmay Exp $
Extract CCSDS packets from a SIIS archive file and write them to level 0 MOC files.
| #define DIM | ( | a | ) | (sizeof (a) / sizeof (*a)) |
Calculate the number of items in an array.
Referenced by add_apid_entry(), close_moc_files(), find_apid_entry(), and main().
| #define GLAST_ID 251 |
Spacecraft ID for GLAST
Referenced by gather_pdu_header().
The typedef for _Apid_Info
| unsigned int add_apid_entry | ( | Apid_Info ** | apid_info_p, | |
| const unsigned short | apid, | |||
| const unsigned short | vcid | |||
| ) | [static] |
Add a new entry in the APID/VCID table for a particular APID and VCID.
| apid_info_p | Pointer to location to store entry pointer. | |
| apid | APID for the packet. | |
| vcid | VCID for the packet. |
References _Apid_Info::apid, DIM, _Apid_Info::exclude, _Apid_Info::moc_file, _Apid_Info::read_count, _Apid_Info::seq_num, _Apid_Info::valid, _Apid_Info::vcid, and _Apid_Info::write_count.
Referenced by get_apid_info(), and parse_command_line().
| unsigned int close_moc_files | ( | void | ) | [static] |
| unsigned int create_moc_file | ( | Apid_Info * | apid_info, | |
| const SIIS_Pdu_Hdr * | pdu_hdr | |||
| ) | [static] |
Create a level 0 MOC file for a CCSDS packet.
| apid_info | Pointer to APID/VCID table entry. | |
| pdu_hdr | Pointer to packet annotation header information. |
References _Apid_Info::apid, _Apid_Info::moc_file, _SIIS_Pdu_Hdr::rcv_time_hi, and _Apid_Info::vcid.
Referenced by get_apid_info().
| unsigned int extract_ccsds_packets | ( | SIIS_Pdu_Hdr * | pdu_hdr, | |
| const unsigned char * | data, | |||
| unsigned int | data_bytes | |||
| ) | [static] |
Extract the CCSDS packets from within a VCDU frame and store them in MOC level 0 files.
| pdu_hdr | Pointer to packet annotation header info. | |
| data | Pointer to start of the VCDU frame data unit zone. | |
| data_bytes | Number of bytes of data within the data unit zone. |
References parse_ccsds_header(), and write_ccsds_packet().
Referenced by process_raw_telem().
| unsigned int find_apid_entry | ( | Apid_Info ** | apid_info_p, | |
| const unsigned short | apid, | |||
| const unsigned short | vcid | |||
| ) | [static] |
Find an entry in the APID/VCID table for a particular APID and VCID.
| apid_info_p | Pointer to location to store entry pointer. | |
| apid | APID for the packet. | |
| vcid | VCID for the packet. |
References DIM, and _Apid_Info::vcid.
Referenced by get_apid_info(), and parse_command_line().
| unsigned int gather_pdu_header | ( | SIIS_Pdu_Hdr * | pdu_hdr, | |
| const unsigned int | vcdu_status, | |||
| const unsigned int | time_tag, | |||
| const SIIS_Vcdu_Hdr * | vcdu_hdr | |||
| ) | [static] |
Gather information that will be stored in a packet annotation header.
| pdu_hdr | Pointer to location to store annotation header info. | |
| vcdu_status | Status from SIIS_vcduGetHdr. | |
| time_tag | Time at which record was written to archive file. | |
| vcdu_hdr | Pointer to VCDU header info for this frame. |
References _SIIS_Vcdu_Hdr::chan_count, _SIIS_Vcdu_Hdr::channel, _SIIS_Pdu_Hdr::frame_channel, _SIIS_Pdu_Hdr::frame_hdr_error, _SIIS_Pdu_Hdr::frame_seq_error, _SIIS_Pdu_Hdr::frame_spacecraft, _SIIS_Pdu_Hdr::frame_version, GLAST_ID, _SIIS_Pdu_Hdr::rcv_time_hi, _SIIS_Vcdu_Hdr::spacecraft, and _SIIS_Vcdu_Hdr::version.
Referenced by process_raw_telem().
| unsigned int get_apid_info | ( | Apid_Info ** | apid_info_p, | |
| const SIIS_Pdu_Hdr * | pdu_hdr, | |||
| const unsigned short | apid | |||
| ) | [static] |
Find the entry in the APID/VCID table for a particular APID and VCID. If there is no entry, then create a new entry and a new level 0 MOC file.
| apid_info_p | Pointer to location to store entry pointer. | |
| pdu_hdr | Pointer to packet annotation header information. | |
| apid | APID for the packet. |
References add_apid_entry(), create_moc_file(), find_apid_entry(), _SIIS_Pdu_Hdr::frame_channel, and Include_All.
Referenced by write_ccsds_packet().
| int main | ( | int | argc, | |
| char * | argv[] | |||
| ) |
The application entry point.
| argc | The number of command line args. | |
| argv | The list of command line args. |
| 0 | Success. | |
| -1 | Failure. |
References Apid_Count, close_moc_files(), DIM, Frame_Count, In_File_Name, Packet_Read_Count, Packet_Write_Count, parse_command_line(), process_record(), SIIS_fileHdrSizeof(), skip_file_data(), start_message_system(), and stop_message_system().
| unsigned int parse_ccsds_header | ( | const unsigned char * | data, | |
| const unsigned int | data_bytes, | |||
| unsigned short * | type, | |||
| unsigned short * | apid, | |||
| unsigned short * | length | |||
| ) | [static] |
Extract information from the header of a CCSDS packet. Note that the 'length' value includes the length of the packet header.
| data | Pointer to start of the packet buffer. | |
| data_bytes | Number of bytes of data in the packet buffer. | |
| type | Pointer to location to return packet type. | |
| apid | Pointer to location to return packet APID. | |
| length | Pointer to location to return packet length. |
References Packet_Read_Count.
Referenced by extract_ccsds_packets().
| unsigned int parse_command_line | ( | int | argc, | |
| char * | argv[] | |||
| ) | [static] |
Interpret the command line parameters.
| argc | The number of command line args. | |
| argv | The list of command line args. |
References add_apid_entry(), _Apid_Info::exclude, find_apid_entry(), In_File_Name, and Include_All.
Referenced by main().
| void print_message | ( | MSG_OutputModes | mode, | |
| void * | prm, | |||
| const MSG_Message * | msg | |||
| ) |
Output processor callback routine to print messages.
| mode | (in) Output processor calling mode | |
| prm | (in) User parameter | |
| msg | (in) Message structure |
printf.
Referenced by start_message_system().
| unsigned int process_raw_telem | ( | const unsigned char * | body, | |
| const unsigned int | body_bytes, | |||
| const unsigned int | time_tag | |||
| ) | [static] |
Process a raw telemetry record from the SIIS archive file. For each CCSDS packet within the record, add a packet annotation header to it and store it into a level 0 MOC file.
| body | Pointer to body of the record. | |
| body_bytes | Number of bytes of data within the record body. | |
| time_tag | Time at which record was written to archive file. |
References _SIIS_Vcdu_Hdr::channel, _SIIS_Vcdu_Hdr::data_offset, extract_ccsds_packets(), _SIIS_Rec_Raw_Telem::frame_bytes, Frame_Count, _SIIS_Rec_Raw_Telem::frame_offset, gather_pdu_header(), SIIS_recGetRawTelem(), SIIS_vcduGetHdr(), and SIIS_vcduTrlSizeof().
Referenced by process_record().
| unsigned int process_record | ( | FILE * | in_file | ) |
Process a record from the SIIS archive file. Do nothing with the record unless it is a raw telemetry record. For raw telemetry records, extract the CCSDS packets and store them in MOC level 0 files.
When finished, the file position indicator for in_file will point to the start of the next record within the archive file.
| in_file | Archive file handle. |
References _SIIS_Rec_Hdr::body_bytes, process_raw_telem(), SIIS_REC_TYPE_RAW_TELEM, SIIS_recGetHdr(), SIIS_recHdrSizeof(), SIIS_recTrlSizeof(), skip_file_data(), _SIIS_Rec_Hdr::time_tag, and _SIIS_Rec_Hdr::type.
Referenced by main().
| unsigned int skip_file_data | ( | FILE * | in_file, | |
| const unsigned int | num_bytes | |||
| ) | [static] |
Read and discard data from a file.
| in_file | File handle. | |
| num_bytes | Number of bytes to read and discard. |
Referenced by main(), and process_record().
| unsigned int start_message_system | ( | void | ) | [static] |
Start the messaging system.
References print_message().
Referenced by main().
| unsigned int stop_message_system | ( | void | ) | [static] |
| unsigned int write_ccsds_packet | ( | SIIS_Pdu_Hdr * | pdu_hdr, | |
| const unsigned char * | data, | |||
| const unsigned int | data_bytes, | |||
| const unsigned short | apid, | |||
| const unsigned short | length | |||
| ) | [static] |
Write a CCSDS packet and packet annotation header to a level 0 MOC file. There is a separate file for each APID/VCID. The file is created if this is the first packet for a given file.
| pdu_hdr | Pointer to packet annotation header information. | |
| data | Pointer to start of the packet buffer. | |
| data_bytes | Number of bytes of data in the packet buffer. | |
| apid | APID for the packet. | |
| length | Length of the packet, in bytes, as reported in its header. |
References Apid_Count, _Apid_Info::exclude, _SIIS_Pdu_Hdr::fill_offset, get_apid_info(), _Apid_Info::moc_file, Packet_Write_Count, _SIIS_Pdu_Hdr::pkt_incomplete, _Apid_Info::read_count, SIIS_mocHdrSizeof(), SIIS_mocPutHdr(), and _Apid_Info::write_count.
Referenced by extract_ccsds_packets().
1.5.8