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.
◆ 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.
|
◆ gcf_parse_cd_status()
Parse a CD status packet.
- Parameters
-
hdr | The already-parsed CD status header. |
block | Pointer to the start of the block data (including 16-byte header). |
out | Pointer to structure into which CD status information will be stored. |
- Return values
-
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
-
| hdr | The already-parsed data block header. |
| block | Pointer to the start of the block data (including 16-byte header). |
[out] | out | Array into which raw samples will be stored. |
- Return values
-
0 | on success. |
-1 | on 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
-
| hdr | The already-parsed data block header. |
| block | Pointer to the start of the block data (including 16-byte header). |
[out] | buf | Memory buffer into which the samples will be written. |
- Return values
-
0 | on success. |
-1 | on 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
-
| hdr | The already-parsed status block header. |
| block | Pointer to the start of the block data (including 16-byte header). |
[out] | out | String buffer into which the status information will be stored. |
- Return values
-
0 | on 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.