GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> QMEM / V0-2-1 > qmem_dump_packets / rhel6-64
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <QMEM/QMEM.h>
Classes | |
struct | _Dump_State |
State information for collecting memory dump datagrams. More... | |
Defines | |
#define | PROG_NAME "qmem_dump_packets" |
#define | STATUS_USAGE ( -1) |
#define | STATUS_BAD_OPEN ( -4) |
#define | STATUS_BAD_CLOSE ( -5) |
#define | STATUS_TRUNCATED (-10) |
#define | STATUS_BAD_PKT (-11) |
#define | STATUS_BAD_ALLOC (-12) |
#define | STATUS_BAD_PARSE (-13) |
#define | STATUS_SHORT_BUFFER (-14) |
Typedefs | |
typedef struct _Dump_State | Dump_State |
Typedef for _Dump_State. | |
Functions | |
static int | show_usage (void) |
Display a usage message for the program. | |
static int | show_bad_packet (unsigned int file_offset) |
Display a bad CCSDS packet message. | |
static int | show_short_buffer (unsigned int buf_bytes, unsigned int bytes_needed) |
Display a short packet buffer message. | |
static int | show_truncated (char *desc, unsigned int file_offset) |
Display a truncated file message. | |
static int | show_qmem_status (QMEM_Status q_status) |
Display QMEM function failure status. | |
static int | alloc (void **alloc_pp, unsigned int num_bytes) |
Allocate memory. | |
static void | display_dump (Dump_State *state_p) |
Display memory dump information. | |
static int | get_ccsds_pkt (Dump_State *state_p) |
Read a CCSDS packet into a packet buffer. | |
static int | parse_buffer (Dump_State *state_p) |
Parse a packet buffer as a memory dump datagram. | |
static int | process_file (FILE *in_file, char *out_fname) |
Read CCSDS packets from a file and process them as datagrams. | |
int | main (int argc, char **argv) |
Entry point for the program. |
** CVS $Id: qmem_dump_packets.c,v 1.3 2011/03/30 23:56:36 russell Exp $ **
This utility extracts memory dump information from a set of CCSDS packets and displays the results.
See the show_usage() function for a description of the options for this program.
int alloc | ( | void ** | alloc_pp, | |
unsigned int | num_bytes | |||
) | [static] |
Allocate memory.
alloc_pp | Location to return pointer to allocated memory. | |
num_bytes | Number of bytes to allocate. |
Referenced by process_file().
void display_dump | ( | Dump_State * | state_p | ) | [static] |
Display memory dump information.
state_p | Pointer to dump state. |
References _Dump_State::ctx_p, _Dump_State::ctx_valid, _Dump_State::out_fname, QMEM_bytes_available(), QMEM_bytes_dumped(), QMEM_data_buf(), QMEM_lat_unit(), QMEM_num_datagrams(), QMEM_start_addr(), and QMEM_tran_id().
Referenced by parse_buffer(), and process_file().
int get_ccsds_pkt | ( | Dump_State * | state_p | ) | [static] |
Read a CCSDS packet into a packet buffer.
state_p | Pointer to dump state. |
References _Dump_State::in_eof, _Dump_State::in_file, _Dump_State::pkt_buf_bytes, _Dump_State::pkt_buf_offset, _Dump_State::pkt_buf_p, show_bad_packet(), show_short_buffer(), and show_truncated().
Referenced by process_file().
int main | ( | int | argc, | |
char ** | argv | |||
) |
Entry point for the program.
argc | Number of command-line arguments. | |
argv | Array of pointers to the command-line arguments. |
References process_file(), and show_usage().
int parse_buffer | ( | Dump_State * | state_p | ) | [static] |
Parse a packet buffer as a memory dump datagram.
state_p | Pointer to dump state. |
References _Dump_State::ctx_p, _Dump_State::ctx_valid, display_dump(), _Dump_State::dump_buf_bytes, _Dump_State::dump_buf_p, _Dump_State::pkt_buf_offset, _Dump_State::pkt_buf_p, QMEM_init_context(), QMEM_parse_datagram(), QMEM_STATUS_NOT_NEXT, QMEM_STATUS_OK, QMEM_STATUS_SHORT, QMEM_STATUS_TRUNCATED, and show_qmem_status().
Referenced by process_file().
int process_file | ( | FILE * | in_file, | |
char * | out_fname | |||
) | [static] |
Read CCSDS packets from a file and process them as datagrams.
in_file | Pointer to input file. | |
out_fname | Name of output file prefix. |
References alloc(), _Dump_State::ctx_p, display_dump(), _Dump_State::dump_buf_bytes, _Dump_State::dump_buf_p, get_ccsds_pkt(), _Dump_State::in_eof, _Dump_State::in_file, _Dump_State::out_fname, parse_buffer(), _Dump_State::pkt_buf_bytes, _Dump_State::pkt_buf_offset, _Dump_State::pkt_buf_p, QMEM_sizeof_context(), and QMEM_sizeof_max_datagram().
Referenced by main().
int show_bad_packet | ( | unsigned int | file_offset | ) | [static] |
Display a bad CCSDS packet message.
file_offset | Current offset within packet file. |
Referenced by get_ccsds_pkt().
int show_qmem_status | ( | QMEM_Status | q_status | ) | [static] |
Display QMEM function failure status.
q_status | Status value returned from QMEM function. |
References QMEM_STATUS_OK.
Referenced by parse_buffer().
int show_short_buffer | ( | unsigned int | buf_bytes, | |
unsigned int | bytes_needed | |||
) | [static] |
Display a short packet buffer message.
buf_bytes | Size, in bytes, of the packet buffer. | |
bytes_needed | Amount of data, in bytes, to store in pkt buffer. |
Referenced by get_ccsds_pkt().
int show_truncated | ( | char * | desc, | |
unsigned int | file_offset | |||
) | [static] |
Display a truncated file message.
desc | Description of current activity. | |
file_offset | Current offset within packet file. |
Referenced by get_ccsds_pkt().
int show_usage | ( | void | ) | [static] |