FrskyParser (frsky_parser v0.1.0) View Source

Parse and store SBus packets coming from FrSky receiver.

Link to this section Summary

Functions

Returns the stored channel values.

Appends the latest data to any leftover data from the previous check_for_new_messages operation.

Empties the stored channel value list.

Create a new FrskyParser struct that can parse new serial data and store the most recently received RX output.

Link to this section Functions

Specs

channels(struct()) :: list()

Returns the stored channel values.

Link to this function

check_for_new_messages(frsky, data)

View Source

Specs

check_for_new_messages(struct(), list()) :: tuple()

Appends the latest data to any leftover data from the previous check_for_new_messages operation.

Arguments are the %FrskyParser{} struct and the newest serial data from the receiver (must already by converted from binary to list)

Returns {%FrskyParser{}, [list of channels]}. If no valid SBus messages was found, the list of channels will be empty.

NOTE: After a valid message has been received, the clear function must be called if you do not want the channel values to persist. Otherwise this function will continue to return a populated channel list even if a new valid message has not been received.

Example:

{frsky_parser, channel_values} = FrskyParser.check_for_new_messages(frsky_parser, new_data_list)
frsky_parser = FrskyParser.clear(frsky_parser)

Specs

clear(struct()) :: struct()

Empties the stored channel value list.

Specs

new() :: struct()

Create a new FrskyParser struct that can parse new serial data and store the most recently received RX output.