GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> FILE / V3-11-1 > file_upl / sun-gcc


Interface   Data Structures   File List   Data Fields   Globals  

FILE_upl.c File Reference

Function definitions for file upload state machine. More...

#include <string.h>
#include <CCSDS/CCSDS_pkt.h>
#include <MDB/MDB_pubdefs.h>
#include <ZLIB/zlib.h>
#include <PBS/RW.h>
#include <FBS/FBS_pubrtos.h>
#include <FILE/FILE_upl.h>
#include <FILE/FILE_upl_cmd.h>
#include <FILE/FILE_upl_msg.h>
#include <FILE_upl_private.h>

Functions

static unsigned int FILE_uplPktStart (FILE_Upl *upl, const unsigned char *pkt, unsigned short length)
static unsigned int FILE_uplPktData (FILE_Upl *upl, const unsigned char *pkt, unsigned short length)
static unsigned int FILE_uplPktCancel (FILE_Upl *upl, const unsigned char *pkt, unsigned short length)
static unsigned int FILE_uplPktCommit (FILE_Upl *upl, const unsigned char *pkt, unsigned short length)
static unsigned int FILE_uplVerify (FILE_Upl *upl, int validateOnly)
static unsigned int FILE_uplError (FILE_Upl *upl, unsigned int errCode, unsigned int errInfo)
FILE_UplFILE_uplGet (void)
 Get a pointer to the file upload state machine descriptor.
unsigned int FILE_uplInit (FILE_Upl *upl, void *fileBuf, unsigned int bufSize)
 Initialize the file upload state machine.
unsigned int FILE_uplExit (FILE_Upl *upl)
 Shutdown the file upload state machine.
unsigned int FILE_uplReset (FILE_Upl *upl)
 Reset the file upload state machine.
unsigned int FILE_uplInfo (FILE_Upl *upl, FILE_Upl_Info *info)
 Get information about the file upload current state.
unsigned int FILE_uplPkt (FILE_Upl *upl, const void *pkt, FILE_Upl_Info *info)
 Announce the arrival of a packet to the state machine.
unsigned int FILE_uplCommit (FILE_Upl *upl, unsigned int id, int validateOnly)
 Announce a file upload commit operation to the state machine.
unsigned int FILE_uplStart (FILE_Upl *upl, unsigned int size)
 Announce a file upload start operation to the state machine.
unsigned int FILE_uplData (FILE_Upl *upl, unsigned int offset, unsigned int size, const void *data)
 Announce a file upload next data operation to the state machine.
unsigned int FILE_uplCancel (FILE_Upl *upl)
 Announce a file upload cancel operation to the state machine.
unsigned int FILE_uplSetError (FILE_Upl *upl, unsigned int errCode)
 Set the file upload state machine error information.

Variables

static FILE_Upl uplDesc


Detailed Description

Function definitions for file upload state machine.

Author:
D.L. Wood

Function Documentation

unsigned int FILE_uplCancel ( FILE_Upl upl  ) 

Announce a file upload cancel operation to the state machine.

Announces the arrival of a new file upload File Upload Data telecommand to the file upload state machine.

Parameters:
upl The upload state machine descriptor.
Returns:
A FILE MSG code.

References _FILE_Upl::check, FILE_UPL_MSG, and FILE_uplReset().

Referenced by FILE_uplPktCancel().

unsigned int FILE_uplCommit ( FILE_Upl upl,
unsigned int  id,
int  validateOnly 
)

Announce a file upload commit operation to the state machine.

PS

Prepares the file data in the upload buffer for writing to storage. Because the actual commit operation is environment specific, this function simple verifies that the file header information and file checksum are valid. Success will set the state of the file upload state machine to FILE_UPL_STATE_COMMIT. This is really a null state, and simply means that the user may now write the data in the upload buffer to storage. Call FILE_uplReset() when done to prepare the state machine for a new upload. The id_commit, and size_commit members are updated in the info structure.

Parameters:
upl The upload state machine descriptor.
id The file ID storage value.
validateOnly 0 = set state to FILE_UPL_STATE_ERROR if validation fails 1 = only return error code if validation fails
Returns:
A FILE MSG code.

References _FILE_Upl::check, FILE_UPL_LOCK, FILE_UPL_MSG, FILE_UPL_STATE_COMMIT, FILE_UPL_STATE_LOAD, FILE_UPL_UNLOCK, FILE_uplError(), FILE_uplVerify(), _FILE_Upl_Info::id_commit, _FILE_Upl::info, and _FILE_Upl_Info::state.

Referenced by FILE_uplPktCommit().

unsigned int FILE_uplData ( FILE_Upl upl,
unsigned int  offset,
unsigned int  size,
const void *  data 
)

Announce a file upload next data operation to the state machine.

Announces the arrival of a new file upload File Upload Data telecommand to the file upload state machine.

Parameters:
upl The upload state machine descriptor.
offset The offset in bytes of the data from the beginning of the file.
size The size in bytes of the upload data.
data A pointer to the upload data.
Returns:
A FILE MSG code.

References _FILE_Upl_Info::buf_addr, _FILE_Upl::check, FILE_UPL_LOCK, FILE_UPL_MSG, FILE_UPL_STATE_LOAD, FILE_UPL_UNLOCK, FILE_uplError(), _FILE_Upl::info, _FILE_Upl_Info::offset_current, _FILE_Upl_Info::pkt_count, _FILE_Upl_Info::size_current, _FILE_Upl_Info::size_total, and _FILE_Upl_Info::state.

Referenced by FILE_uplPktData().

static unsigned int FILE_uplError ( FILE_Upl upl,
unsigned int  errCode,
unsigned int  errInfo 
) [static]

Records error information about file uploads.

Parameters:
upl The upload state machine descriptor.
errCode The FILE MSG code indicating the error.
errInfo Parameter value to use when reporting error.
Returns:
A FILE MSG code.

References FILE_UPL_MSG, and FILE_uplSetError().

Referenced by FILE_uplCommit(), FILE_uplData(), FILE_uplPkt(), FILE_uplPktCancel(), FILE_uplPktCommit(), FILE_uplPktStart(), FILE_uplStart(), and FILE_uplVerify().

unsigned int FILE_uplExit ( FILE_Upl upl  ) 

Shutdown the file upload state machine.

Released resources allocated by the file upload state machine. Note that releasing the file upload assembly buffer passed in the call to FILE_uplInit() is the user's responsibility.

Parameters:
upl The upload state machine descriptor.
Returns:
A FILE MSG code.

References _FILE_Upl::check, FILE_UPL_MSG, and _FILE_Upl::info_lock.

FILE_Upl * FILE_uplGet ( void   ) 

Get a pointer to the file upload state machine descriptor.

Returns a pointer to the global file upload state machine descriptor.

Returns:
The upload state machine descriptor.

unsigned int FILE_uplInfo ( FILE_Upl upl,
FILE_Upl_Info info 
)

Get information about the file upload current state.

Returns information about the current file upload state.

Parameters:
upl The upload state machine descriptor.
info Filled in with current state info upon return.
Returns:
A FILE MSG code.

References _FILE_Upl::check, FILE_UPL_LOCK, FILE_UPL_MSG, FILE_UPL_UNLOCK, and _FILE_Upl::info.

Referenced by FILE_uplPkt().

unsigned int FILE_uplInit ( FILE_Upl upl,
void *  fileBuf,
unsigned int  bufSize 
)

Initialize the file upload state machine.

Initializes the file upload state machine.

Parameters:
upl The upload state machine descriptor.
fileBuf A pointer to a buffer that the loader can use for assembly of complete files from packet data fragments.
bufSize The size in bytes of fileBuf. This is also the largest size for a file upload.
Returns:
A FILE MSG code.

References _FILE_Upl_Info::buf_addr, _FILE_Upl::buf_size, _FILE_Upl::check, _FILE_Upl::chksum_size, FILE_UPL_MSG, FILE_uplReset(), _FILE_Upl::hdr_size, _FILE_Upl::info, and _FILE_Upl::info_lock.

unsigned int FILE_uplPkt ( FILE_Upl upl,
const void *  pkt,
FILE_Upl_Info info 
)

Announce the arrival of a packet to the state machine.

Announces the arrival of a new file upload telecommand CCSDS packet to the file upload state machine. On return, the state of the file upload, after processing the current packet, is given in info. If an error is encoutered, the upload state is set to FILE_UPL_STATE_ERROR.

Parameters:
upl The upload state machine descriptor.
pkt A pointer to the CCSDS file upload telecommand packet.
info Filled in with current state info upon return.
Returns:
A FILE MSG code.

References _FILE_Upl::check, FILE_APID_LAT_FILE_LOAD, FILE_UPL_MSG, FILE_uplError(), FILE_uplInfo(), FILE_uplPktCancel(), FILE_uplPktCommit(), FILE_uplPktData(), and FILE_uplPktStart().

static unsigned int FILE_uplPktCancel ( FILE_Upl upl,
const unsigned char *  pkt,
unsigned short  length 
) [static]

Announces the arrival of a new file upload File Upload Data telecommand CCSDS packet to the file upload state machine.

Parameters:
upl The upload state machine descriptor.
pkt A pointer to the CCSDS file upload telecommand packet.
length The size in bytes of the telecommand packet application data.
Returns:
A FILE MSG code.

References _FILE_Upl::chksum_size, FILE_uplCancel(), and FILE_uplError().

Referenced by FILE_uplPkt().

static unsigned int FILE_uplPktCommit ( FILE_Upl upl,
const unsigned char *  pkt,
unsigned short  length 
) [static]

Prepares the file data in the upload buffer for writing to storage. Because the actual commit operation is environment specific, this function simple verifies that the file header information and file checksum are valid. Success will set the state of the file upload state machine to FILE_UPL_STATE_COMMIT. This is really a null state, and simply means that the user may now write the data in the upload buffer to storage. Call FILE_uplReset() when done to prepare the state machine for a new upload. The id_commit, and size_commit members are updated in the info structure.

Parameters:
upl The upload state machine descriptor.
pkt A pointer to the CCSDS file upload telecommand packet.
length The size in bytes of the telecommand packet application data.
Returns:
A FILE MSG code.

References _FILE_Upl::chksum_size, FILE_uplCommit(), FILE_uplError(), _FILE_Upl::hdr_size, and LFILEUPCOMMIT_FILEFLAGS_VO.

Referenced by FILE_uplPkt().

static unsigned int FILE_uplPktData ( FILE_Upl upl,
const unsigned char *  pkt,
unsigned short  length 
) [static]

Announces the arrival of a new file upload File Upload Data telecommand CCSDS packet to the file upload state machine.

Parameters:
upl The upload state machine descriptor.
pkt A pointer to the CCSDS file upload telecommand packet.
length The size in bytes of the telecommand packet application data.
Returns:
A FILE MSG code.

References _FILE_Upl::chksum_size, FILE_uplData(), and _FILE_Upl::hdr_size.

Referenced by FILE_uplPkt().

static unsigned int FILE_uplPktStart ( FILE_Upl upl,
const unsigned char *  pkt,
unsigned short  length 
) [static]

Announces the arrival of a new file upload File Upload Start telecommand CCSDS packet to the file upload state machine.

Parameters:
upl The upload state machine descriptor.
pkt A pointer to the CCSDS file upload telecommand packet.
length The size in bytes of the telecommand packet application data.
Returns:
A FILE MSG code.

References _FILE_Upl::chksum_size, FILE_uplError(), FILE_uplStart(), and _FILE_Upl::hdr_size.

Referenced by FILE_uplPkt().

unsigned int FILE_uplReset ( FILE_Upl upl  ) 

Reset the file upload state machine.

Resets the file upload state machine. All error conditions and previous file load state are cleared. A File Upload Start telecommand must be issued to start a new upload.

Parameters:
upl The upload state machine descriptor.
Returns:
A FILE MSG code.

References _FILE_Upl_Info::buf_addr, _FILE_Upl::buf_size, _FILE_Upl::check, _FILE_Upl_Info::error_code, _FILE_Upl_Info::error_count, FILE_UPL_CLEAR, FILE_UPL_LOCK, FILE_UPL_MSG, FILE_UPL_STATE_START, FILE_UPL_UNLOCK, _FILE_Upl_Info::id_commit, _FILE_Upl::info, _FILE_Upl_Info::offset_current, _FILE_Upl_Info::pkt_count, _FILE_Upl_Info::size_commit, _FILE_Upl_Info::size_current, _FILE_Upl_Info::size_total, and _FILE_Upl_Info::state.

Referenced by FILE_uplCancel(), and FILE_uplInit().

unsigned int FILE_uplSetError ( FILE_Upl upl,
unsigned int  errCode 
)

Set the file upload state machine error information.

Records error information about file uploads. This can be used to update the file upload error state.

Parameters:
upl The upload state machine descriptor.
errCode The FILE MSG code indicating the error.
Returns:
A FILE MSG code.

References _FILE_Upl::check, _FILE_Upl_Info::error_code, _FILE_Upl_Info::error_count, FILE_UPL_LOCK, FILE_UPL_MSG, FILE_UPL_STATE_ERROR, FILE_UPL_UNLOCK, _FILE_Upl::info, and _FILE_Upl_Info::state.

Referenced by FILE_uplError().

unsigned int FILE_uplStart ( FILE_Upl upl,
unsigned int  size 
)

Announce a file upload start operation to the state machine.

Announces the arrival of a new file upload File Upload Start telecommand CCSDS packet to the file upload state machine.

Parameters:
upl The upload state machine descriptor.
size The maximum size in bytes of the upload data set.
Returns:
A FILE MSG code.

References _FILE_Upl::buf_size, _FILE_Upl::check, FILE_UPL_LOCK, FILE_UPL_MSG, FILE_UPL_STATE_LOAD, FILE_UPL_STATE_START, FILE_UPL_UNLOCK, FILE_uplError(), _FILE_Upl::info, _FILE_Upl_Info::size_total, and _FILE_Upl_Info::state.

Referenced by FILE_uplPktStart().

static unsigned int FILE_uplVerify ( FILE_Upl upl,
int  validateOnly 
) [static]

Verifies that the complete file data set has arrived correctly. The file header is examined for integrety, and the file data checksum is validated.

Parameters:
upl The upload state machine descriptor.
validateOnly 0 = set state to FILE_UPL_STATE_ERROR if validation fails 1 = only return error code if validation fails
Returns:
A FILE MSG code.

References _FILE_Upl_Info::buf_addr, FILE_UPL_LOCK, FILE_UPL_MSG, FILE_UPL_UNLOCK, FILE_uplError(), _FILE_Upl::info, _FILE_Upl_Info::size_commit, and _FILE_Upl_Info::size_total.

Referenced by FILE_uplCommit().


Variable Documentation

uplDesc [static]

Private data descriptor for file upload state machine.


Generated on Wed Nov 21 20:59:42 2012 by  doxygen 1.5.8