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

Constituent: lsep_write     Tag: linux-gcc


Interface   Data Structures   File List   Data Fields   Globals  

lsep_write.c File Reference

Test program for writing LAT Science Data from EBF file. More...

#include <dprintf.h>
#include "CCSDS/CCSDS_pkt.h"
#include "CDM/CDM_pubdefs.h"
#include "PBS/BSWP.h"
#include "LSEP/LSEP_ids.h"
#include "LSEP/LSEPW.h"
#include "CDFP.h"
#include "CDFP_def.h"
#include "LSE/CDF_gem.h"
#include "LSE/LSE_time.h"
#include "LSE/CCSDS_ostream.h"
#include "EDS/EBF_dir.h"
#include "EDS/EBF_match.h"
#include "EDS/EDS_fw.h"
#include "EDS/EDS_cfg.h"
#include "EDS/FFS.h"
#include "EDS/io/EBF_stream.h"
#include "EDS/io/LCBP.h"
#include "EDS/io/EBF_swap.h"
#include "EDS/LCBV.h"
#include "EDS/TMR.h"
#include "LSF/LSF_cpu.h"
#include "LSF/LSF_mode.h"
#include "LSF/LSF_origin.h"
#include "LSF/LSF_reason.h"
#include "EFC_DB/EH_ids.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <string.h>
#include <libgen.h>

Include dependency graph for lsep_write.c:


Data Structures

struct  _StrDsc
 Defines a string descriptor as a length and a pointer. More...
struct  _FileNamBlk
 Describes a file name as consisting of 3 pieces, a directory, a name, and an extension. More...
struct  _HandlerCtx
 Bogus handler context for testing purposes. More...
struct  _PostStream
 Post Stream Services + Context Parameter. More...
struct  _File
 Definition of a file. More...
struct  _OutputFiles
 Managing structure for the output files. More...
struct  _PostSeqSpec
 Post Sequence Specification. More...
struct  _PostCtx
 Combines the EDS posting services with its context parameter. More...
struct  _ModeSeqSpec
 Mode Sequence Specification. More...
struct  _ModeSeqCtx
 Captures the Mode Sequence Context. More...
struct  _Ctl
 Collections all the control parameters together. These are essentially the interpretted command line options. More...
struct  _PostHandler
 Binds a posting routine with its parameter. More...

The fully qualified name of the output file to create

static PostHandler post_handler_get (int fd, int ccsdsFlag)
 Sets up the physical posting routine plus its context parameter.
static int postCtxConstruct (PostCtx *ctx, Ctl *ctl)
 Constructs the posting context.
static int postStart (PostCtx *ctx, int reason, unsigned int run_id, unsigned int startTime, unsigned int mode, unsigned int hw_key, unsigned int cfg_key)
 Callback routine when a posting queue is started, i.e. made ready to receive events.
static void postWrite (PostCtx *ctx, EDS_fwIxb *ixb)
 Callback routine to write an event to the post stream.
static int postNotify (PostCtx *ctx, unsigned int mode, unsigned int active, const EDS_cfgInfo cfgs[32], const EDS_rsdTbl *rsdTbl)
 Routine to notify clients of a change in the handlers' configuration.
static int postFlush (PostCtx *ctx, int reason)
 Callback routine for the event post que flushing Status 0, success, anything else failure.
static int modeSelect (HandlerCtx *ctx, unsigned int mode, EDS_cfgInfo *info)
 Mode select routine for the toy handlers.
static void msxConstruct (ModeSeqCtx *ctx, EDS_fw *fw, const ModeSeqSpec *mss, unsigned int handlers, unsigned int ostreams)
 Constructs a Mode Sequence Context from the Mode Sequence Specification.
static unsigned int msxService (ModeSeqCtx *msx)
 Routine that is responsible for determining whether to do a mode switch for the next event.
static int file_create (const char *name)
 Creates the output file.

Defines

#define RND_TO(_x, _r)   ((((_x) + (_r) -1) / (_r)) * (_r))
 Rounds the specified number, _x up to the nearest multiple of _r.

Typedefs

typedef _StrDsc StrDsc
 Typedef for struct _StrDsc.
typedef _FileNamBlk FileNamBlk
 Typedef for struct _FileNamBlk.
typedef _HandlerCtx HandlerCtx
 Typedef for struct _HandlerCtx.
typedef _PostStream PostStream
 Typedef for struct _PostStream.
typedef _File File
 Typedef for a file.
typedef _OutputFiles OutputFiles
 Typedef for struct _OutputFiles.
typedef _PostSeqSpec PostSeqSpec
 Typedef for struct _PostSeqSpec.
typedef _PostCtx PostCtx
 Typedef for struct _PostCtx.
typedef _ModeSeqSpec ModeSeqSpec
 Typedef for struct _ModeSeqSpec.
typedef _ModeSeqCtx ModeSeqCtx
 Typedef for struct _ModeSeqCtx.
typedef _Ctl Ctl
 Typedef for struct _Ctl.
typedef _PostHandler PostHandler
 Typedef for struct _PostHandler.

Functions

static LSEPW * lsepw_allocate (int level)
 Sizes and allocates an LSEPW control structure.
static unsigned int * ccsds_post (void *prm, void *buf, int nbytes)
 Routine to write the data for the CCSDS ostream.
static unsigned int * buf_post (void *prm, void *buf, int nbytes)
 Routine to write the data to a file.
static unsigned int * dummy_post (void *prm, void *buf, int nbytes)
 Dummy event posting routine.
static CDFP_cfgcdfp_cfg_allocate (int level)
 Sizes and allocates an CDFP configuration structure.
static unsigned int getObjects (HandlerCtx *ctx)
 Returns the objects needed by this handler.
static unsigned int getNeeds (HandlerCtx *ctx)
 Returns the needs of this handler.
static unsigned int getResultSize (HandlerCtx *ctx)
 Returns the needs of this handler.
static unsigned int evt_lcbd_handler (ModeSeqCtx *msx, unsigned int edw, EBF_pkt *pkt)
 LCBD event handler call back routine.
static unsigned int output (Ctl *ctl)
 Finishes the platform common setup and initalization, starts the packet flow.
static void reportUsage (void)
 Brief explanation on readtest usage.
unsigned int evt_handler (HandlerCtx *ctx, unsigned int pktBytes, void *pkt, unsigned int siv, EDS_fwIxb *ixb, int id)
 Dummy event handler.
static int fillCtl (Ctl *ctl, int argc, char *const argv[])
 Examines the command line parameters and fills the output control structure.
int main (int argc, char *const argv[])
 Usual entry point for lsep_write.
static void parse (FileNamBlk *nam, const char *filename, unsigned int opts)
 Breaks a file name into its components.
static const char * compose (char *name, const char *iname, const FileNamBlk *relblk, int apid, const char *defext)
static int loadLib (const char *library_name, int verbose)
 Dynamically loads the specified configuration library.
static void getKeys (const char *s, unsigned int *hkey, unsigned int *skey, unsigned int *ckey)
 Parses the input for hardware (LATC) and software (Boot Script) and configuration (LPA_DB) keys. The format is a comma separated list of up two three items of the form.
static time_t getTime (const char *s)
 Parses an input time specification to produce a 32-bit time value.
static void addHandler (HandlerCtx *handler, int idx, const char *s, unsigned int reassemble)
 Parses and adds a handler.
static void addOutputFile (OutputFiles *output, const char *s)
 Captures the names of the output files.
static int initHandler (HandlerCtx *handler, int objects, unsigned int reassemble)
 Initializes a default handler context.
static __inline int count_chr (const char *s, char c)
 Counts the number of times c appears in the string s.
static void report_flag_err (const char *reason, const char *s, int count)
 Issue an error message when the parsing of the flag sequence options string is not specified correctly.
static void report_mss_err (const char *reason, const char *s, int count)
 Issue an error message when the parsing of the flag sequence options string is not specified correctly.
static LSE_timeFlagSpec * constructTfs (const char *s, unsigned int *flags)
 Constructs a Time Flag Specification orders.
static ModeSeqSpecconstructMss (const char *s)
 Constructs a Mode Sequence Specification orders.
static void report_pss_err (const char *reason, const char *s, int count)
 Issue an error message when the parsing of the Posting sequence options string is not specified correctly.
static PostSeqSpecconstructPss (const char *s)
 Constructs a list of Post Sequence Specification orders.

Variables

static unsigned short int Apids [4]
 The APIDs as a function of CPU number.

Detailed Description

Test program for writing LAT Science Data from EBF file.

Author:
JJRussell - russell@slac.stanford.edu
Usage
Example:
    $ lsep_write -n<# of events> -s<# to skip> <file.ebf>
   

For a complete explanation type lsep_write with no arguments.
    CVS $Id: lsep_write.c,v 1.27 2008/09/02 22:26:50 russell Exp $

Define Documentation

#define RND_TO _x,
_r   )     ((((_x) + (_r) -1) / (_r)) * (_r))
 

Rounds the specified number, _x up to the nearest multiple of _r.

Returns:
The rounded number
Parameters:
_x The number to round
_r The number to round up to


Typedef Documentation

ModeSeqSpec
 

Typedef for struct _ModeSeqSpec.

This is used to simulate the progression of the operating mode. Each specification consists of a value for the mode and the number of events this mode should persist for. It is used to test the mode changing features.


Function Documentation

static void addHandler HandlerCtx handler,
int  idx,
const char *  s,
unsigned int  reassemble
[static]
 

Parses and adds a handler.

Parameters:
handler The handler context to complete
idx Installation index, this fills the purpose of the handler's index in the LPA_DB master file
s The parameter string
reassemble The mask of contributors to reassemble
The parameter string has the format
<handler_id>:<cfg_id>:<result_size>

static void addOutputFile OutputFiles output,
const char *  s
[static]
 

Captures the names of the output files.

Parameters:
output The output control structure
s The command line parameter string. This must of one of the two following forms
  • -o<filename>
  • -o<n>=<filename> where must be 0-3, which represent EPU0, EPU1, EPU2 and the SIU (the SIU is treated as a logical, there is only one.)

unsigned int * buf_post void *  prm,
void *  buf,
int  nbytes
[static]
 

Routine to write the data to a file.

Returns:
Pointer to the next buffer to be filled
Parameters:
prm Arbitrary user parameter, here it is the file handle
buf The buffer to output
nbytes The size of the output buffer, in bytes.

unsigned int * ccsds_post void *  prm,
void *  buf,
int  nbytes
[static]
 

Routine to write the data for the CCSDS ostream.

Returns:
Pointer to the next buffer to be filled
Parameters:
prm Arbitrary user parameter, here it is the file handle
buf The buffer to output
nbytes The size of the output buffer, in bytes.

static CDFP_cfg * cdfp_cfg_allocate int  level  )  [static]
 

Sizes and allocates an CDFP configuration structure.

Parameters:
level The desired compression level

static ModeSeqSpec * constructMss const char *  s  )  [static]
 

Constructs a Mode Sequence Specification orders.

Returns:
A pointer to the constructed list of orders
Parameters:
s The string to parse

static PostSeqSpec * constructPss const char *  s  )  [static]
 

Constructs a list of Post Sequence Specification orders.

Returns:
A pointer to the constructed list of orders
Parameters:
s The string to parse

static LSE_timeFlagSpec * constructTfs const char *  s,
unsigned int *  flags
[static]
 

Constructs a Time Flag Specification orders.

Returns:
A pointer to the constructed list of orders
Parameters:
s The string to parse
flags Filled in with the initial value of the timetone flags word.

static __inline int count_chr const char *  s,
char  c
[static]
 

Counts the number of times c appears in the string s.

Returns:
The number of times c appears in the string s
Parameters:
s The string to examine
c The character to count

unsigned int * dummy_post void *  prm,
void *  buf,
int  nbytes
[static]
 

Dummy event posting routine.

Returns:
Pointer to the next buffer to be filled
Parameters:
prm Arbitrary user parameter, ignored
buf The buffer to output
nbytes The size of the output buffer, in bytes.

unsigned int evt_handler HandlerCtx ctx,
unsigned int  pktBytes,
void *  pkt,
unsigned int  siv,
EDS_fwIxb *  ixb,
int  id
 

Dummy event handler.

Return values:
EDS_FW_FN_M_OUTPUT to force the event to be output
Parameters:
ctx Handler' context
pktBytes Number of bytes in the packet, ignored
pkt Pointer to the event data, ignored
siv The State Information Vector, ignored
ixb The Information Exchange Block
id The EDS_fw id of this handler

static unsigned int evt_lcbd_handler ModeSeqCtx msx,
unsigned int  edw,
EBF_pkt *  pkt
[static]
 

LCBD event handler call back routine.

Parameters:
msx The Mode Sequence Context
edw Event descriptor word
pkt Event packet

static int file_create const char *  name  )  [static]
 

Creates the output file.

Returns:
The output file descriptor

static int fillCtl Ctl ctl,
int  argc,
char *const   argv[]
[static]
 

Examines the command line parameters and fills the output control structure.

Parameters:
ctl The parameter control block.
argc The number of command line parameters.
argv The array of pointers to the command line parameters.
Return values:
0,Everything is okay.
-1,Incorrect command usage. Usually this means that the input file name was absent.

static void getKeys const char *  s,
unsigned int *  hkey,
unsigned int *  skey,
unsigned int *  ckey
[static]
 

Parses the input for hardware (LATC) and software (Boot Script) and configuration (LPA_DB) keys. The format is a comma separated list of up two three items of the form.

  • h=value (hardware key)
  • l=value (software key)
  • c=value (configuration key)

Parameters:
s The string to parse
hkey Returned as the hardware key
skey Returned as the software key
ckey Returned as the configuration key

static unsigned int getNeeds HandlerCtx ctx  )  [static]
 

Returns the needs of this handler.

Returns:
The bit list of needs
Parameters:
ctx The handler's context

static unsigned int getObjects HandlerCtx ctx  )  [static]
 

Returns the objects needed by this handler.

Returns:
The bit list of needed objects
Parameters:
ctx The handler's context

static unsigned int getResultSize HandlerCtx ctx  )  [static]
 

Returns the needs of this handler.

Returns:
The size of the result vector
Parameters:
ctx The Handler context structure

time_t getTime const char *  s  )  [static]
 

Parses an input time specification to produce a 32-bit time value.

Returns:
The time in seconds elapsed since the Unix Epoch
Parameters:
s The string to parse Fmt mm/dd/yy:hh:mm:ss

static int initHandler HandlerCtx handler,
int  objects,
unsigned int  reassemble
[static]
 

Initializes a default handler context.

Parameters:
handler The handler context to initialize
objects The list of additional objects to add
reassemble The list of contributors to reassemble

static int loadLib const char *  library_name,
int  verbose
[static]
 

Dynamically loads the specified configuration library.

Return values:
0,success 
-1,failure 
Parameters:
library_name The name of the library to load
verbose The verbosity level

static LSEPW * lsepw_allocate int  level  )  [static]
 

Sizes and allocates an LSEPW control structure.

Parameters:
level The desired compression level

int main int  argc,
char *const   argv[]
 

Usual entry point for lsep_write.

Parameters:
argc The number of arguments
argv The vector of arguments.
For usage type lsep_write with no arguments

static int modeSelect HandlerCtx ctx,
unsigned int  mode,
EDS_cfgInfo *  info
[static]
 

Mode select routine for the toy handlers.

Returns:
The new configuration identifier
Parameters:
ctx The handler context
mode The new operating mode
info Returned as the configuration information for newly selected mode.

static void msxConstruct ModeSeqCtx msx,
EDS_fw *  fw,
const ModeSeqSpec mss,
unsigned int  handlers,
unsigned int  ostreams
[static]
 

Constructs a Mode Sequence Context from the Mode Sequence Specification.

Parameters:
msx The Mode Sequecne Context to construct
fw The EDS framework handle, used to locate the object in the IXB and set as a handle in the constructed object
mss The Mode Sequence Specification used to do the construction
handlers The list of event handlers
ostreams The list of output streams

static unsigned int msxService ModeSeqCtx msx  )  [static]
 

Routine that is responsible for determining whether to do a mode switch for the next event.

Parameters:
msx The mode sequence context
This is a mode switch simulation routine. It is installed as the reset function of the MSX object registered with EDS. As such, it is called back once at the end of every event. The routine checks its context to determine whether a mode switch should be made before the next event is processed.

static unsigned int output Ctl ctl  )  [static]
 

Finishes the platform common setup and initalization, starts the packet flow.

Parameters:
ctl The control structure

static void parse FileNamBlk nam,
const char *  filename,
unsigned int  opts
[static]
 

Breaks a file name into its components.

Parameters:
filename The file name to break down
nam The name block to fill in
opts A bit options mask,
  • Bit 0, means ignore the extension from the input file name
  • Bit 1, means ignore the base name from the input file name
  • Bit 2, means ignore the directory from the input file name

static PostHandler post_handler_get int  fd,
int  no_ccsds
[static]
 

Sets up the physical posting routine plus its context parameter.

Returns:
The post handler
Parameters:
fd The output file descriptor, may be 0
no_ccsds Whether on wants the output not packetized as CCSDS

static int postCtxConstruct PostCtx ctx,
Ctl ctl
[static]
 

Constructs the posting context.

Return values:
==0,Success 
!=0,Error 
Parameters:
ctx The posting context to construct
ctl The control block; acts as the source of the configuration information

static int postFlush PostCtx ctx,
int  reason
[static]
 

Callback routine for the event post que flushing Status 0, success, anything else failure.

Parameters:
ctx The posting context
reason The reason for flushing the ques

static int postNotify PostCtx ctx,
unsigned int  mode,
unsigned int  active,
const EDS_cfgInfo  cfgs[32],
const EDS_rsdTbl *  rsdTbl
[static]
 

Routine to notify clients of a change in the handlers' configuration.

Returns:
0 on success, else non-zero
Parameters:
ctx The posting context
mode The new mode
active List of the currently active handlers
cfgs The array of configurations, indexed by handler number
rsdTbl The table of result summary data table

static int postStart PostCtx ctx,
int  reason,
unsigned int  run_id,
unsigned int  startTime,
unsigned int  mode,
unsigned int  hw_key,
unsigned int  cfg_key
[static]
 

Callback routine when a posting queue is started, i.e. made ready to receive events.

Returns:
0 is successful, non-zero otherwise
Parameters:
ctx Post context parameter
reason Suggested use is to indicate why the post stream is being started
run_id Suggested use is to identify the block of events between when EDS_fwStart is called and EDS_fwFlush is called with a stop reason
startTime The run start time rounded to the nearest second
mode This must be the running mode.
hw_key The hardware configuration file key
cfg_key The software configuration file key. This likely a reference to how event handlers to EDS here configured (perhaps the LPA_DB key).

static void postWrite PostCtx ctx,
EDS_fwIxb *  ixb
[static]
 

Callback routine to write an event to the post stream.

Parameters:
ctx The post context parameter
ixb The framework's Information Exchange Block

static void report_flag_err const char *  reason,
const char *  s,
int  count
[static]
 

Issue an error message when the parsing of the flag sequence options string is not specified correctly.

Parameters:
reason A string representing the reason
s The mis-specified string
count The count (index into the string) where the error occurred

static void report_mss_err const char *  reason,
const char *  s,
int  count
[static]
 

Issue an error message when the parsing of the flag sequence options string is not specified correctly.

Parameters:
reason A string representing the reason
s The mis-specified string
count The count (index into the string) where the error occurred

static void report_pss_err const char *  reason,
const char *  s,
int  count
[static]
 

Issue an error message when the parsing of the Posting sequence options string is not specified correctly.

Parameters:
reason A string representing the reason
s The mis-specified string
count The count (index into the string) where the error occurred


Variable Documentation

static unsigned short int Apids[4] [static]
 

Initial value:

 
{
    APID_K_BASE + 1,  
    APID_K_BASE + 2,  
    APID_K_BASE + 3,  
    APID_K_BASE       
}
The APIDs as a function of CPU number.


Generated on Sun Jun 14 01:22:59 2009 by  doxygen 1.4.4