GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LSE / V2-1-0 > lsew_stream / rad750
#include <LSE/CCSDS_ostream.h>
#include <CCSDS/CCSDS_pkt.h>
#include <EDS/io/EBF_swap.h>
#include <dprintf.h>
#include <stdlib.h>
#include <string.h>
Classes | |
struct | _CCSDS_ostream |
The Post Control Block. More... | |
Defines | |
#define | RND_TO(_x, _r) ((((_x) + (_r) -1) / (_r)) * (_r)) |
Rounds the specified number, _x up to the nearest multiple of _r. | |
#define | MAX_WRITE (4096 - 32) |
The maximum size, in bytes, of an LCB packet. | |
Typedefs | |
typedef struct _CCSDS_ostream | CCSDS_ostream |
Typedef for struct _CCSDS_stream. | |
Functions | |
static __inline void | setUnused (unsigned char *cur, int offset, unsigned short int unused_bytes) |
Sets the last short integer before the start of the data proper to the number of unused bytes written to the output packet. | |
static void | post (void *buf, int nbytes, int nhdr, int nunused, CCSDS_ostreamPoster postRtn, void *postPrm) |
Posts the specified buffer using the specified posting routine and parameter. The CCSDS header and data are appropriately byte-swapped to big-endian style if necessary. | |
int | CCSDS_ostreamDestroy (CCSDS_ostream *ostream) |
Frees any resources associated with the specified stream. | |
CCSDS_ostream * | CCSDS_ostreamNew (void) |
Allocates enough memory for, but does not initialize an CCSDS_ostream structure. | |
int | CCSDS_ostreamSizeof (void) |
Returns the size, in bytes, of the CCSDS output stream control structure CCSDS_ostream. | |
void | CCSDS_ostreamConstruct (CCSDS_ostream *ostream, CCSDS_ostreamPoster postRtn, void *postPrm, unsigned short int sequence, unsigned short int max_write) |
Constructs/Initializes the Post Control Block. | |
void * | CCSDS_ostreamPost (CCSDS_ostream *ostream, void *buf, int nbytes) |
Routine to write the data to post the data. The buffer is broken in multiple CCSDS packets, with the size limited to 4096-128 bytes. |
CVS $Id: CCSDS_ostream.c,v 1.7 2011/03/26 17:35:23 russell Exp $
#define RND_TO | ( | _x, | |||
_r | ) | ((((_x) + (_r) -1) / (_r)) * (_r)) |
Rounds the specified number, _x up to the nearest multiple of _r.
_x | The number to round | |
_r | The number to round up to |
Referenced by CCSDS_ostreamConstruct(), CCSDS_ostreamPost(), and post().
void CCSDS_ostreamConstruct | ( | CCSDS_ostream * | ostream, | |
CCSDS_ostreamPoster | postRtn, | |||
void * | postPrm, | |||
unsigned short int | sequence, | |||
unsigned short int | max_write | |||
) |
Constructs/Initializes the Post Control Block.
ostream | The output stream handle | |
postRtn | The user provide physical posting routine | |
postPrm | The user provide parameter to the post routine | |
sequence | The starting CCSDS sequence number to use. This is almost always 0, but is provided as a parameter for testing purposes | |
max_write | The maximum packet size to be written. This must be at least 32 (although why anyone would make it that small would be a mystery) and no bigger than 4096 - 32. If it is not a multiple of 16 bytes, it will be rounded up to the nearest 16 bytes boundary and then limited to the maximum of 4096 - 32. |
References _CCSDS_ostream::dat_offset, _CCSDS_ostream::hdr_size, _CCSDS_ostream::max_data, _CCSDS_ostream::max_write, MAX_WRITE, _CCSDS_ostream::postPrm, _CCSDS_ostream::postRtn, RND_TO, and _CCSDS_ostream::sequence.
int CCSDS_ostreamDestroy | ( | CCSDS_ostream * | ostream | ) |
Frees any resources associated with the specified stream.
ostream | The output stream handle to destroy |
CCSDS_ostream* CCSDS_ostreamNew | ( | void | ) |
Allocates enough memory for, but does not initialize an CCSDS_ostream structure.
void* CCSDS_ostreamPost | ( | CCSDS_ostream * | ostream, | |
void * | buf, | |||
int | nbytes | |||
) |
Routine to write the data to post the data. The buffer is broken in multiple CCSDS packets, with the size limited to 4096-128 bytes.
ostream | The output stream handle | |
buf | The buffer to output | |
nbytes | The size of the output buffer, in bytes. |
References DPRINTF, _CCSDS_ostream::hdr_size, _CCSDS_ostream::max_data, _CCSDS_ostream::max_write, post(), _CCSDS_ostream::postPrm, _CCSDS_ostream::postRtn, RND_TO, and _CCSDS_ostream::sequence.
int CCSDS_ostreamSizeof | ( | void | ) |
Returns the size, in bytes, of the CCSDS output stream control structure CCSDS_ostream.
void post | ( | void * | buf, | |
int | nbytes, | |||
int | nhdr, | |||
int | nunused, | |||
CCSDS_ostreamPoster | postRtn, | |||
void * | postPrm | |||
) | [static] |
Posts the specified buffer using the specified posting routine and parameter. The CCSDS header and data are appropriately byte-swapped to big-endian style if necessary.
buf | The buffer to post | |
nbytes | The size, in bytes, of the buffer, including the header. This must be a multiple of 4-bytes. | |
nhdr | The number of bytes in the header. This most be a multiple of 4 bytes less 2 bytes for the pad word. | |
nunused | The number of unused (pad bytes) needed to round the actual payload to a multiple of 4 bytes | |
postRtn | The posting routine | |
postPrm | The posting parameter |
References RND_TO, and setUnused().
Referenced by CCSDS_ostreamPost().
static __inline void setUnused | ( | unsigned char * | cur, | |
int | offset, | |||
unsigned short int | unused_bytes | |||
) | [static] |
Sets the last short integer before the start of the data proper to the number of unused bytes written to the output packet.
cur | The base pointer | |
offset | The byte offset from cur to the 16-bit address to store the number of unused bytes | |
unused_bytes | The number of unused bytes that are padding the data packet |
Referenced by post().