libdata-gcf  1.1.2
Data Structures | Enumerations | Functions
Block parsing.

Data Structures

struct  gcf_cd_status
 CD status packet.The Continuous Data standard (from the CTBTO) requires some additional real-time status updates. These updates are sent in a CD status packet, which is decoded into a struct gcf_cd_status. More...
 

Enumerations

enum  gcf_cd_gps_fix_t { gcf_cd_gps_fix_no_comms, gcf_cd_gps_fix_none, gcf_cd_gps_fix_2d, gcf_cd_gps_fix_3d }
 CD status: GPS fix. More...
 
enum  gcf_cd_gps_mode_t { gcf_cd_gps_mode_auto, gcf_cd_gps_mode_manual }
 CD status: GPS control mode. More...
 

Functions

int gcf_parse_cd_status (const struct gcf_generic_hdr *hdr, const char *block, struct gcf_cd_status *out)
 Parse a CD status packet. More...
 
int gcf_parse_data (const struct gcf_data_hdr *hdr, const char *block, int32_t *out))
 Parse a data block into a fixed array. More...
 
int gcf_parse_data_membuf (const struct gcf_data_hdr *hdr, const char *block, struct membuf_t *buf))
 Parse a data block into a memory buffer. More...
 
int gcf_parse_status (const struct gcf_status_hdr *hdr, const char *block, char *out)
 Parse a status block. More...
 

Detailed Description

This module contains a set of routines for parsing various block types. Data blocks are decoded into an array of integers representing the raw sample values, status blocks have their text extracted into a string, and CD or unified status packets have their data extracted into a specific structure.

Enumeration Type Documentation

◆ gcf_cd_gps_fix_t

CD status: GPS fix.

Enumerator
gcf_cd_gps_fix_no_comms 

No GPS unit attached.

gcf_cd_gps_fix_none 

No fix.

gcf_cd_gps_fix_2d 

2D only fix.

gcf_cd_gps_fix_3d 

Full 3D fix.

◆ gcf_cd_gps_mode_t

CD status: GPS control mode.

Enumerator
gcf_cd_gps_mode_auto 

Automatic.

gcf_cd_gps_mode_manual 

Manual.

Function Documentation

◆ gcf_parse_cd_status()

int gcf_parse_cd_status ( const struct gcf_generic_hdr hdr,
const char *  block,
struct gcf_cd_status out 
)

Parse a CD status packet.

Parameters
hdrThe already-parsed CD status header.
blockPointer to the start of the block data (including 16-byte header).
outPointer to structure into which CD status information will be stored.
Return values
0on success.
-1on error (and see gcf_errstr).

Decodes the information contained in a CD status block, storing the result in out. If the information is in some way invalid, this is recorded in gcf_errstr and -1 is returned. Otherwise, out contains the result and 0 is returned.

◆ gcf_parse_data()

int gcf_parse_data ( const struct gcf_data_hdr hdr,
const char *  block,
int32_t *  out 
)

Parse a data block into a fixed array.

Parameters
hdrThe already-parsed data block header.
blockPointer to the start of the block data (including 16-byte header).
[out]outArray into which raw samples will be stored.
Return values
0on success.
-1on error (and see gcf_errstr, errno).

This function will extract the raw data samples from a data block. The raw samples are signed 32-bit values representing the absolute value recorded by the digitiser's ADC. The array out must be large enough to hold all of the decompressed samples.

On success, 0 is returned. On failure, -1 is returned and errno and gcf_errstr are set. On failure, the value of errno determines whether anything was written to out:

  • ENOTSUP — The encoding format is not understood. out will be unmodified.
  • EOVERFLOW — The last sample does not match the RIC (reverse integrating constant). out will contain samples, but their values may be incorrect (effectively a checksum error).
  • EDOM — The first difference is not zero. out will contain samples, but their values may be incorrect (the first difference is ignored).

◆ gcf_parse_data_membuf()

int gcf_parse_data_membuf ( const struct gcf_data_hdr hdr,
const char *  block,
struct membuf_t *  buf 
)

Parse a data block into a memory buffer.

Parameters
hdrThe already-parsed data block header.
blockPointer to the start of the block data (including 16-byte header).
[out]bufMemory buffer into which the samples will be written.
Return values
0on success.
-1on error (and see gcf_errstr, errno).

This function will extract the raw data samples from a data block. The raw samples are signed 32-bit values representing the absolute value recorded by the digitiser's ADC.

On success, 0 is returned. On failure, -1 is returned and errno and gcf_errstr are set. On failure, the value of errno determines whether anything was written to buf:

  • ENOTSUP — The encoding format is not understood. buf will be unmodified.
  • EOVERFLOW — The last sample does not match the RIC (reverse integrating constant). buf will contain samples, but their values may be incorrect (effectively a checksum error).
  • EDOM — The first difference is not zero. buf will contain samples, but their values may be incorrect (the first difference is ignored).

◆ gcf_parse_status()

int gcf_parse_status ( const struct gcf_status_hdr hdr,
const char *  block,
char *  out 
)

Parse a status block.

Parameters
hdrThe already-parsed status block header.
blockPointer to the start of the block data (including 16-byte header).
[out]outString buffer into which the status information will be stored.
Return values
0on success (cannot fail).

This function will extract the status information from a status block. The information is simply copied into the output buffer out, and then null terminated. The buffer out must be large enough to hold all the status information and the terminating null byte. In general, it must be at least 1009 bytes large.

Note
This function can also be used to parse byte pipe and infoblock blocks.