Module: util/PacketParser

Parses data received from the data relay into a usable format for the ground station's event emitters

Author:
  • Serge Babayan
Source:
See:

Requires

Methods


<inner> checkForMissingHeaders(headers_array)

Compares the received headers to that of the headers in the PacketTypes module. Warns the user if there are extra or missing headers

Parameters:
Name Type Description
headers_array Array
Source:

<inner> parseData(data, headers_array)

Converts a string of data into a packet type object, to be emitted by the TelemetryData module. Uses the PacketTypes module in order to sort the headers into the appropriate packet types as well as to perform the correct validations on each one

Parameters:
Name Type Description
data string

A stringified version of the data (split by commas)

headers_array Array

An array of the headers in the same order as the headers

Source:
Throws:

Error if the specified validation function doesn't exist

Returns:

A hash indexed by the packet type name, with the values being another hash in a format of header_name => data_value

Type
Object
Example

Given '34, 89.654, ...' as data and ['heading', 'lon', ...] as headers, will return:

{
   aircraft_position: {
     heading: 34,
     lon: 89.654
     ...
   },
   aircraft_orientation: {...},
   aircraft_gains: {...}
   ...
}