GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > QSE / V1-6-3

Constituent: qsd     Tag: sun-gcc


Interface   Data Structures   File List   Data Fields   Globals  

CCSDS_istream.c File Reference

Input CCSDS packets. More...

#include "QSE/CCSDS_istream.h"
#include "QSE/CCSDS_apidDsc.h"
#include "CCSDS/CCSDS_pkt.h"
#include "MSG/MSG_macdefs.h"
#include "PBS/BSWP.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <errno.h>
#include <sys/time.h>

Include dependency graph for CCSDS_istream.c:


Data Structures

struct  _CCSDS_istreamInput
 Function callbacks to read and close an input stream. More...
struct  _CCSDS_istream
 The control structure/context for reading a CCSDS formatted stream of bytes. More...

Defines

#define CCSDS_M_SEQ   0x3fff
 Mask of the valid bits in the CCSDS sequence number.
#define SA_UTB_OFFSET   0x3a4fc880
 The offset between Spectrum-Astro Epoch and UTB.

Typedefs

typedef _CCSDS_istreamInput CCSDS_istreamInput
 Typedef for struct _CCSDS_istreamInput.

Functions

static __inline void swapToBig (unsigned int *a32, int n32)
 Halfword swaps the specified number of 32-bit integers to big endian representation. This is a NOOP on big endian machines.
static int __inline form_transition (unsigned int siv, unsigned short int flags)
 Forms the new state transition word. This consists of 2 bits defining the previous packet state (ONLY, FIRST, MIDDLE, LAST) and 2 bits defining the current packet state.
static int __inline check_transition (unsigned int state)
 Checks that the transition from the previous state to the current state is allowed.
static int file_read (FILE *file, unsigned char *buf, int nbytes, int pbytes)
 Simple routine to do a file read using fread.
static CCSDS_istreamconstruct (CCSDS_istream *istream, int free)
 Construct for a newly minted CCSDS_istream structure.
int CCSDS_istreamSizeof (void)
 Returns the size, in bytes, of a CCSDS_istream structure.
CCSDS_istreamCCSDS_istreamNew (void)
 Convenience function to allocate and initialize a CCSDS_istream control structure.
int CCSDS_istreamConstruct (CCSDS_istream *istream)
 Constructs (initializes) a previously uninitialized CCSDS_istream control structure.
int CCSDS_istreamConnect (CCSDS_istream *istream, void *prm, CCSDS_istreamReader read, CCSDS_istreamCloser close, CCSDS_istreamTeller tell)
 Connects a read mechanism with the specified stream.
int CCSDS_istreamHdrRead (CCSDS_istream *istream, CCSDS_istreamHdr *hdr)
 Reads the CCSDS header.
int CCSDS_istreamDatRead (CCSDS_istream *istream, const CCSDS_istreamHdr *hdr, CCSDS_apidDsc *dsc)
 Reads the current CCSDS data payload into the buffer specified by dsc.
int CCSDS_istreamFileOpen (CCSDS_istream *istream, const char *filename, unsigned int options, unsigned char *buf, unsigned int buf_size)
 Convenience function to construct a CCSDS_istream to read from the specified named file filename.
unsigned int CCSDS_istreamTell (const CCSDS_istream *istream)
 Returns the current byte offset into the stream.
int CCSDS_istreamClose (CCSDS_istream *istream)
 Closes the input stream associated with istream.
int CCSDS_istreamDestroy (CCSDS_istream *istream)
 Destroys (i.e. returns the resources) associated with the stream.
void CCSDS_istreamHdrPrint (const CCSDS_istreamHdr *hdr)
 Prints a one-line summary of the CCSDS_istream header.

Detailed Description

Input CCSDS packets.

Author:
JJRussell - russell@slac.stanford.edu
   CVS $Id: CCSDS_istream.c,v 1.7 2006/05/08 17:47:08 russell Exp $

Define Documentation

#define SA_UTB_OFFSET   0x3a4fc880
 

The offset between Spectrum-Astro Epoch and UTB.

Parameters:
SA_UTB_OFFSET 


Function Documentation

int CCSDS_istreamClose CCSDS_istream istream  ) 
 

Closes the input stream associated with istream.

Returns:
Status
Parameters:
istream The stream to close
Note:
This does not free/destroy the istream control structure, it merely closes the physical stream associated with it.

int CCSDS_istreamConnect CCSDS_istream istream,
void *  prm,
CCSDS_istreamReader  read,
CCSDS_istreamCloser  close,
CCSDS_istreamTeller  tell
 

Connects a read mechanism with the specified stream.

Return values:
0,Always 
Parameters:
istream The target CCSDS_istream
prm Arbitrary user context parameter passed to the read routine
read The routine used to read from the underlying physical data stream
close The routine used to close the underlying physical stream
tell The routine used to get the current position in the stream.

int CCSDS_istreamConstruct CCSDS_istream istream  ) 
 

Constructs (initializes) a previously uninitialized CCSDS_istream control structure.

Return values:
==0,Successful 
!=0,Failure (currently the routine always succeeds
Parameters:
istream The CCSDS_istream structure to construct (initialize)

int CCSDS_istreamDatRead CCSDS_istream istream,
const CCSDS_istreamHdr hdr,
CCSDS_apidDsc dsc
 

Reads the current CCSDS data payload into the buffer specified by dsc.

Returns:
The State Information Vector. This is a heavily bit-encoded 32-bit word, see CCSDS_ISTREAM_SIV_M, for example for the meanings of these bits. Consult the dsc->status word for more information
Parameters:
istream The target CCSDS_istream structure
hdr The header associated with the data about to be read
dsc The target APIDs descriptor
If there was insufficient space in the descriptor's read buffer to perform the read, no bytes are read, but rather, the return value is set to indicate insufficient space and the descriptor's status word (dsc->status) is set to the number of bytes needed. The user may increase the descriptors read buffer side and then recall this routine.

int CCSDS_istreamDestroy CCSDS_istream istream  ) 
 

Destroys (i.e. returns the resources) associated with the stream.

Returns:
Status
Parameters:
istream The stream to destroy.

int CCSDS_istreamFileOpen CCSDS_istream istream,
const char *  filename,
unsigned int  options,
unsigned char *  buf,
unsigned int  buf_size
 

Convenience function to construct a CCSDS_istream to read from the specified named file filename.

Returns:
0, If successful

-1, If could not allocate a new stream (i.e. out of memory)

-2, If the file does not exist XS

Parameters:
istream The target CCSDS_istream
filename The name of the file to open
options Bit list of options, currently unused, specify as 0
buf Optional parameter specifying the FILE's input read buffer
buf_size Optional parameter specifying the size of buf

void CCSDS_istreamHdrPrint const CCSDS_istreamHdr hdr  ) 
 

Prints a one-line summary of the CCSDS_istream header.

Parameters:
hdr The header to print

int CCSDS_istreamHdrRead CCSDS_istream istream,
CCSDS_istreamHdr hdr
 

Reads the CCSDS header.

Return values:
0,Success 
-1,End Of Stream
Anything else, error number (errno)
Parameters:
istream The target CCSDS_istream
hdr The destination CCSDS header

CCSDS_istream * CCSDS_istreamNew void   ) 
 

Convenience function to allocate and initialize a CCSDS_istream control structure.

Returns:
Pointer to the allocated CCSDS_istream control structure

int CCSDS_istreamSizeof void   ) 
 

Returns the size, in bytes, of a CCSDS_istream structure.

Returns:
The size, in bytes, of a CCSDS_istream structure

unsigned int CCSDS_istreamTell const CCSDS_istream istream  ) 
 

Returns the current byte offset into the stream.

Returns:
The current byte offset into the stream, i.e. the read pointer
Parameters:
istream The target CCSDS_istream

static int __inline check_transition unsigned int  state  )  [static]
 

Checks that the transition from the previous state to the current state is allowed.

Return values:
0,Transition is allowed
!=0,Transition is not allowed
Parameters:
state The 4-bit state transition word
This routine checks that the transition from the transition of the previous packet to the state of the current packet is allowed.

static CCSDS_istream * construct CCSDS_istream istream,
int  free
[static]
 

Construct for a newly minted CCSDS_istream structure.

Returns:
istream
Parameters:
istream The structure to initialize
free If non-zero, this structure should be freed by CCSDS_istreamFree

static int file_read FILE *  file,
unsigned char *  buf,
int  nbytes,
int  pbytes
[static]
 

Simple routine to do a file read using fread.

Return values:
0,Success 
-1,End Of Stream
Anything else, error number (errno)
Parameters:
file The file stream to read from
buf The buffer, guaranteed to be nbytes in length
nbytes The number of data bytes
pbytes The number of pad bytes, these bytes should be discarded This number is guaranteed to be no larger than 16.

static int __inline form_transition unsigned int  siv,
unsigned short int  flags
[static]
 

Forms the new state transition word. This consists of 2 bits defining the previous packet state (ONLY, FIRST, MIDDLE, LAST) and 2 bits defining the current packet state.

Parameters:
siv The state information vector containing the state of the previous packet
flags The flags bit of current CCSDS packet as returned by the CCSDS packet query routines
The state of packet is defined as ONLY packet or the FIRST, MIDDLE of LAST of a sequence.

void swapToBig unsigned int *  a32,
int  n32
[static]
 

Halfword swaps the specified number of 32-bit integers to big endian representation. This is a NOOP on big endian machines.

Parameters:
a32 The array of words to swap
n32 The number of words to half_word swap


Generated on Thu Jul 12 01:47:28 2007 by  doxygen 1.4.4