ASTERIX data record processing. More...

Collaboration diagram for Data Record:

Data Structures

struct  ast_datarecord_t
 Datarecord. More...
struct  ast_datarecord_ex_t
 Extracted datarecord. More...
struct  ast_datarecord_modifier_t
 Datarecord modifier. More...

Macros

#define AST_MAX_DATAITEMS   32
 Maximum number of data items in a data record.
#define AST_DATARECORD_HEX_HTML_PREFERED_CHARS   (AST_MAX_DATAITEMS * AST_MAX_DATAITEM_SIZE * 12 + 128)
 Preferred number of chars of datarecord hexadecimal HTML snippet.
#define AST_DATARECORD_DETAIL_HTML_PREFERED_CHARS   20480
 Preferred number of chars of data item detail description HTML snippet.
#define AST_KEYWORD_VALUE_PREFERRED_CHARS   32
 Preferred number of chars of keyword string.

Functions

ast_datarecord_t ast_datarecord_decode (const unsigned char *buffer, const size_t bufsize, const ast_category_t category, const ast_uap_t uap)
 Datarecord decode function.
ast_datarecord_t ast_datarecord_encode (unsigned char *const buffer, const size_t bufsize, const ast_datarecord_ex_t xdr)
 Datarecord encode function.
ast_datarecord_t ast_datarecord_copy (unsigned char *buffer, const size_t bufsize, const ast_datarecord_t src)
 Datarecord copy function.
ast_datarecord_t ast_datarecord_modify (unsigned char *buffer, const size_t bufsize, const ast_datarecord_t src, const ast_datarecord_modifier_t mod)
 Datarecord modify function.
void ast_datarecord_get_hex_html (char *html, const size_t html_size, const ast_datarecord_t dr)
 Function to get a html snippet of the raw datarecord data in hexadecimal format.
void ast_datarecord_get_detail_html (char *detail, const size_t detail_size, const ast_datarecord_t dr)
 Function to get a html snippet of detailed description of data record.
bool ast_datarecord_contain_keyword (const ast_datarecord_t dr, const ast_keyword_t keyword)
 Check if datarecord contains specified keyword type.
bool ast_datarecord_match_keyword (const ast_datarecord_t dr, const ast_keyword_t keyword, const char *challenge, bool case_sensitive)
 Match a specified keyword in the datarecord.
bool ast_datarecord_get_keyword (char *keystr, const size_t keystr_size, const ast_datarecord_t dr, const ast_keyword_t keyword, const ast_keyword_format_t format)
 Get keyword summary string from specified datarecord.
ast_sacsic_t ast_datarecord_get_sacsic (const ast_datarecord_t dr)
 Get SAC/SIC from specified datarecord.
ast_timeofday_t ast_datarecord_get_timeofday (const ast_datarecord_t dr)
 Get time of day from specified datarecord.
ast_msgtype_t ast_datarecord_get_msgtype (const ast_datarecord_t dr)
 Get message type from specified datarecord.
ast_tracknum_t ast_datarecord_get_tracknum (const ast_datarecord_t dr)
 Get track number from specified datarecord.
ast_squawk_t ast_datarecord_get_squawk (const ast_datarecord_t dr)
 Get Mode-3/A code from specified datarecord.
ast_callsign_t ast_datarecord_get_callsign (const ast_datarecord_t dr)
 Get callsign from specified datarecord.
ast_icaoaddr_t ast_datarecord_get_icaoaddr (const ast_datarecord_t dr)
 Get ICAO 24-bit address from specified datarecord.
ast_wgs84coord_t ast_datarecord_get_wgs84coord (const ast_datarecord_t dr)
 Get WGS-84 coordinate from specified datarecord.
ast_altitude_t ast_datarecord_get_flightlevel (const ast_datarecord_t dr)
 Get flight level from specified datarecord.
ast_altitude_t ast_datarecord_get_selaltitude (const ast_datarecord_t dr)
 Get FMS/MCP/FCU selected altitude from specified datarecord.
ast_polar_coordinate_t ast_datarecord_get_polarcoord (const ast_datarecord_t dr)
 Get polar coordinate from specified datarecord.
ast_range_t ast_datarecord_get_range (const ast_datarecord_t dr)
 Get range from specified datarecord.
ast_azimuth_t ast_datarecord_get_azimuth (const ast_datarecord_t dr)
 Get azimuth from specified datarecord.
ast_heading_t ast_datarecord_get_heading (const ast_datarecord_t dr)
 Get heading from specified datarecord.
ast_speed_t ast_datarecord_get_speed (const ast_datarecord_t dr)
 Get speed from specified datarecord.
ast_cartesian_velocity_t ast_datarecord_get_cartesianvel (const ast_datarecord_t dr)
 Get cartesian velocity from specified datarecord.
ast_doppler_velocity_t ast_datarecord_get_dopplervel (const ast_datarecord_t dr)
 Get doppler velocity from specified datarecord.
ast_vertical_rate_t ast_datarecord_get_vrate (const ast_datarecord_t dr)
 Get vertical rate from specified datarecord.

Detailed Description

ASTERIX data record processing.

Description:
A data record is a collection of data items belonging to the same Category, composed according to the User Application Profile (UAP) and prefixed by a Field Specification (FSPEC).

Macro Definition Documentation

◆ AST_DATARECORD_DETAIL_HTML_PREFERED_CHARS

#define AST_DATARECORD_DETAIL_HTML_PREFERED_CHARS   20480

Preferred number of chars of data item detail description HTML snippet.

◆ AST_DATARECORD_HEX_HTML_PREFERED_CHARS

#define AST_DATARECORD_HEX_HTML_PREFERED_CHARS   (AST_MAX_DATAITEMS * AST_MAX_DATAITEM_SIZE * 12 + 128)

Preferred number of chars of datarecord hexadecimal HTML snippet.

◆ AST_KEYWORD_VALUE_PREFERRED_CHARS

#define AST_KEYWORD_VALUE_PREFERRED_CHARS   32

Preferred number of chars of keyword string.

Examples
example.c.

◆ AST_MAX_DATAITEMS

#define AST_MAX_DATAITEMS   32

Maximum number of data items in a data record.

Function Documentation

◆ ast_datarecord_contain_keyword()

bool ast_datarecord_contain_keyword ( const ast_datarecord_t dr,
const ast_keyword_t keyword )

Check if datarecord contains specified keyword type.

Parameters
drdatarecord to check
keywordkeyword type
Returns
true if contain, false if not contain

◆ ast_datarecord_copy()

ast_datarecord_t ast_datarecord_copy ( unsigned char * buffer,
const size_t bufsize,
const ast_datarecord_t src )

Datarecord copy function.

Parameters
bufferBuffer to write destination datarecord data
bufsizeBuffer size
srcOriginal data record, must be valid

This function will copy original data record, to specified buffer. If all fields in data record has been successfully copied, the returned datarecord will be marked as "valid". If any error occurs, the returned datarecord will be marked as "invalid".

◆ ast_datarecord_decode()

ast_datarecord_t ast_datarecord_decode ( const unsigned char * buffer,
const size_t bufsize,
const ast_category_t category,
const ast_uap_t uap )

Datarecord decode function.

Parameters
bufferBuffer to read datarecord data
bufsizeBuffer size
categoryData category
uapUser application profile (UAP) used to decode data

This function will read and check data against specified uap, and return decoded datarecord. If data can be successfully decoded, the returned datarecord will be marked as "valid". If any error occurs, the returned datarecord will be marked as "invalid".

◆ ast_datarecord_encode()

ast_datarecord_t ast_datarecord_encode ( unsigned char *const buffer,
const size_t bufsize,
const ast_datarecord_ex_t xdr )

Datarecord encode function.

Parameters
bufferBuffer to write encoded datarecord data
bufsizeBuffer size
xdrExtracted datarecord container
Returns
Encoded datarecord

This function will check dataitems contained in xdr, encode them and write encoded data to buffer. If all data items are successfully encoded, the returned datarecord will be marked as "valid". If any error occurs, the returned datarecord will be marked as "invalid".

◆ ast_datarecord_get_azimuth()

ast_azimuth_t ast_datarecord_get_azimuth ( const ast_datarecord_t dr)

Get azimuth from specified datarecord.

Parameters
drdatarecord to get
Returns
Azimuth, if azimuth doesn't exist, the azimuth will be set to invalid

◆ ast_datarecord_get_callsign()

ast_callsign_t ast_datarecord_get_callsign ( const ast_datarecord_t dr)

Get callsign from specified datarecord.

Parameters
drdatarecord to get
Returns
the callsign, if doesn't exist, it will be set to invalid

◆ ast_datarecord_get_cartesianvel()

ast_cartesian_velocity_t ast_datarecord_get_cartesianvel ( const ast_datarecord_t dr)

Get cartesian velocity from specified datarecord.

Parameters
drdatarecord to get
Returns
cartesian velocity, if velocity doesn't exist, the velocity will be set to invalid

◆ ast_datarecord_get_detail_html()

void ast_datarecord_get_detail_html ( char * detail,
const size_t detail_size,
const ast_datarecord_t dr )

Function to get a html snippet of detailed description of data record.

Parameters
detailBuffer to save the html snippet
detail_sizeBuffer size
drDatarecord

The returned html fragment contains only basic elements used in html body, such as <br/> <h> <table>....

This function will return only semantics markups, some elements will contain class name, and it is recommended for the library user to use CSS to format the html style.

◆ ast_datarecord_get_dopplervel()

ast_doppler_velocity_t ast_datarecord_get_dopplervel ( const ast_datarecord_t dr)

Get doppler velocity from specified datarecord.

Parameters
drdatarecord to get
Returns
doppler velocity, if velocity doesn't exist, the velocity will be set to invalid

◆ ast_datarecord_get_flightlevel()

ast_altitude_t ast_datarecord_get_flightlevel ( const ast_datarecord_t dr)

Get flight level from specified datarecord.

Parameters
drdatarecord to get
Returns
level, if level doesn't exist, the level will be set to invalid

◆ ast_datarecord_get_heading()

ast_heading_t ast_datarecord_get_heading ( const ast_datarecord_t dr)

Get heading from specified datarecord.

Parameters
drdatarecord to get
Returns
heading, if both magnetic and geographic headings don't exist, the heading will be set to invalid

◆ ast_datarecord_get_hex_html()

void ast_datarecord_get_hex_html ( char * html,
const size_t html_size,
const ast_datarecord_t dr )

Function to get a html snippet of the raw datarecord data in hexadecimal format.

The returned text will be an html table with data in the cells.

◆ ast_datarecord_get_icaoaddr()

ast_icaoaddr_t ast_datarecord_get_icaoaddr ( const ast_datarecord_t dr)

Get ICAO 24-bit address from specified datarecord.

Parameters
drdatarecord to get
Returns
the ICAO 24-bit address, if doesn't exist, it will be set to invalid

◆ ast_datarecord_get_keyword()

bool ast_datarecord_get_keyword ( char * keystr,
const size_t keystr_size,
const ast_datarecord_t dr,
const ast_keyword_t keyword,
const ast_keyword_format_t format )

Get keyword summary string from specified datarecord.

Parameters
keystrthe summary string of specified keyword value
keystr_sizethe buffer size of keystr
drdatarecord to get
keywordkeyword type
formatkeyword format
Returns
true if keyword is found, false if keyword doesn't exist.

For different keyword, the summary string will include:

  • AST_KEYWORD_TRACKNUM, track number string. E.g. "912"
  • AST_KEYWORD_CALLSIGN, original non-trimmed callsign string, in ASCII encoding. E.g. "CCA931 "
Examples
example.c.

◆ ast_datarecord_get_msgtype()

ast_msgtype_t ast_datarecord_get_msgtype ( const ast_datarecord_t dr)

Get message type from specified datarecord.

Parameters
drdatarecord to get
Returns
the message type, if message type doesn't apply, it will be set to invalid

◆ ast_datarecord_get_polarcoord()

ast_polar_coordinate_t ast_datarecord_get_polarcoord ( const ast_datarecord_t dr)

Get polar coordinate from specified datarecord.

Parameters
drdatarecord to get
Returns
Polar coordinate, if coordinate doesn't exist, the coordinate will be set to invalid

◆ ast_datarecord_get_range()

ast_range_t ast_datarecord_get_range ( const ast_datarecord_t dr)

Get range from specified datarecord.

Parameters
drdatarecord to get
Returns
Range, if range doesn't exist, the range will be set to invalid

◆ ast_datarecord_get_sacsic()

ast_sacsic_t ast_datarecord_get_sacsic ( const ast_datarecord_t dr)

Get SAC/SIC from specified datarecord.

Parameters
drdatarecord to get
Returns
the SAC/SIC, if SAC/SIC doesn't exist (only when datarecord is corrupted), it will be set to invalid

◆ ast_datarecord_get_selaltitude()

ast_altitude_t ast_datarecord_get_selaltitude ( const ast_datarecord_t dr)

Get FMS/MCP/FCU selected altitude from specified datarecord.

Parameters
drdatarecord to get
Returns
level, if altitude doesn't exist, the level will be set to invalid

◆ ast_datarecord_get_speed()

ast_speed_t ast_datarecord_get_speed ( const ast_datarecord_t dr)

Get speed from specified datarecord.

Parameters
drdatarecord to get
Returns
speed, if speed doesn't exist, the speed will be set to invalid

◆ ast_datarecord_get_squawk()

ast_squawk_t ast_datarecord_get_squawk ( const ast_datarecord_t dr)

Get Mode-3/A code from specified datarecord.

Parameters
drdatarecord to get
Returns
the squawk, if doesn't exist, it will be set to invalid

◆ ast_datarecord_get_timeofday()

ast_timeofday_t ast_datarecord_get_timeofday ( const ast_datarecord_t dr)

Get time of day from specified datarecord.

Parameters
drdatarecord to get
Returns
the time of day, if time doesn't exist, it will be set to invalid

◆ ast_datarecord_get_tracknum()

ast_tracknum_t ast_datarecord_get_tracknum ( const ast_datarecord_t dr)

Get track number from specified datarecord.

Parameters
drdatarecord to get
Returns
the track number, if track number doesn't exist, it will be set to invalid

◆ ast_datarecord_get_vrate()

ast_vertical_rate_t ast_datarecord_get_vrate ( const ast_datarecord_t dr)

Get vertical rate from specified datarecord.

Parameters
drdatarecord to get
Returns
vertical rate, if vertical rate doesn't exist, the vertical rate will be set to invalid

◆ ast_datarecord_get_wgs84coord()

ast_wgs84coord_t ast_datarecord_get_wgs84coord ( const ast_datarecord_t dr)

Get WGS-84 coordinate from specified datarecord.

Parameters
drdatarecord to get
Returns
coord WGS-84 coordinate, if coordinate doesn't exist, the coordinate will be set to invalid

◆ ast_datarecord_match_keyword()

bool ast_datarecord_match_keyword ( const ast_datarecord_t dr,
const ast_keyword_t keyword,
const char * challenge,
bool case_sensitive )

Match a specified keyword in the datarecord.

Parameters
drdatarecord to match
keywordtype of keyword
challengec string of keyword
case_sensitivecase sensitive
Returns
true if successfully match; false if not

◆ ast_datarecord_modify()

ast_datarecord_t ast_datarecord_modify ( unsigned char * buffer,
const size_t bufsize,
const ast_datarecord_t src,
const ast_datarecord_modifier_t mod )

Datarecord modify function.

Parameters
bufferBuffer to write modified datarecord data
bufsizeBuffer size
srcOriginal data record, must be valid
modData item modifier

This function will modify the original data record, according to data item modifier, and write modified data into buffer. For data items not specified by data modifier, the original one will be copied as is. If all data items can be successfully modified, the returned datarecord will be marked as "valid". If any error occurs, the returned datarecord will be marked as "invalid".