dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
frsky_packing.c File Reference

Packs UAVObjects into FrSKY Smart Port frames. More...

#include "frsky_packing.h"
#include "modulesettings.h"
#include "misc_math.h"
#include "physical_constants.h"
#include "attitudeactual.h"
#include "baroaltitude.h"
#include "positionactual.h"
#include "velocityactual.h"
#include "flightbatterystate.h"
#include "flightbatterysettings.h"
#include "gpstime.h"
#include "homelocation.h"
#include "accels.h"
#include "flightstatus.h"
#include "airspeedactual.h"
#include "nedaccel.h"

Go to the source code of this file.

Functions

bool frsky_encode_altitude (struct frsky_settings *frsky, uint32_t *value, bool test_presence_only, uint32_t arg)
 
bool frsky_encode_gps_course (struct frsky_settings *frsky, uint32_t *value, bool test_presence_only, uint32_t arg)
 
bool frsky_encode_vario (struct frsky_settings *frsky, uint32_t *value, bool test_presence_only, uint32_t arg)
 
bool frsky_encode_current (struct frsky_settings *frsky, uint32_t *value, bool test_presence_only, uint32_t arg)
 
bool frsky_encode_cells (struct frsky_settings *frsky, uint32_t *value, bool test_presence_only, uint32_t arg)
 
bool frsky_encode_t1 (struct frsky_settings *frsky, uint32_t *value, bool test_presence_only, uint32_t arg)
 
bool frsky_encode_t2 (struct frsky_settings *frsky, uint32_t *value, bool test_presence_only, uint32_t arg)
 
bool frsky_encode_fuel (struct frsky_settings *frsky, uint32_t *value, bool test_presence_only, uint32_t arg)
 
bool frsky_encode_acc (struct frsky_settings *frsky, uint32_t *value, bool test_presence_only, uint32_t arg)
 
bool frsky_encode_gps_coord (struct frsky_settings *frsky, uint32_t *value, bool test_presence_only, uint32_t arg)
 
bool frsky_encode_gps_alt (struct frsky_settings *frsky, uint32_t *value, bool test_presence_only, uint32_t arg)
 
bool frsky_encode_gps_speed (struct frsky_settings *frsky, uint32_t *value, bool test_presence_only, uint32_t arg)
 
bool frsky_encode_gps_time (struct frsky_settings *frsky, uint32_t *value, bool test_presence_only, uint32_t arg)
 
bool frsky_encode_rpm (struct frsky_settings *frsky, uint32_t *value, bool test_presence_only, uint32_t arg)
 
bool frsky_encode_airspeed (struct frsky_settings *frsky, uint32_t *value, bool test_presence_only, uint32_t arg)
 
uint8_t frsky_insert_byte (uint8_t *obuff, uint16_t *chk, uint8_t byte)
 
int32_t frsky_send_frame (uintptr_t com, enum frsky_value_id id, uint32_t value, bool send_prelude)
 

Detailed Description

Packs UAVObjects into FrSKY Smart Port frames.

Author
dRonin, http://dRonin.org/, Copyright (C) 2016
Tau Labs, http://taulabs.org, Copyright (C) 2015 Since there is no public documentation of SmartPort protocol available, this was put together by studying OpenTx source code, reading tidbits of informations on the Internet and experimenting.
See Also
https://github.com/opentx/opentx/tree/next/radio/src/telemetry
https://code.google.com/p/telemetry-convert/wiki/FrSkySPortProtocol
The GNU Public License (GPL) Version 3

Definition in file frsky_packing.c.

Function Documentation

bool frsky_encode_acc ( struct frsky_settings frsky,
uint32_t *  value,
bool  test_presence_only,
uint32_t  arg 
)

Encode configured values

Parameters
[out]valueencoded value
[in]test_presence_onlytrue when function should only test for availability of this value
[in]argargument specified in frsky_value_items[]; 0=X, 1=Y, 2=Z
Returns
true when value succesfully encoded or presence test passed

Definition at line 296 of file frsky_packing.c.

bool frsky_encode_airspeed ( struct frsky_settings frsky,
uint32_t *  value,
bool  test_presence_only,
uint32_t  arg 
)

Encode true airspeed(TAS)

Parameters
[out]valueencoded value
[in]test_presence_onlytrue when function should only test for availability of this value
[in]argargument specified in frsky_value_items[]
Returns
true when value succesfully encoded or presence test passed

Definition at line 559 of file frsky_packing.c.

bool frsky_encode_altitude ( struct frsky_settings frsky,
uint32_t *  value,
bool  test_presence_only,
uint32_t  arg 
)

Encode baro altitude value

Parameters
[out]valueencoded value
[in]test_presence_onlytrue when function should only test for availability of this value
[in]argargument specified in frsky_value_items[]
Returns
true when value succesfully encoded or presence test passed

Definition at line 62 of file frsky_packing.c.

bool frsky_encode_cells ( struct frsky_settings frsky,
uint32_t *  value,
bool  test_presence_only,
uint32_t  arg 
)

Encode battery cells voltage

Parameters
[out]valueencoded value
[in]test_presence_onlytrue when function should only test for availability of this value
[in]argargument specified in frsky_value_items[], index of battery cell pair
Returns
true when value succesfully encoded or presence test passed

Definition at line 153 of file frsky_packing.c.

bool frsky_encode_current ( struct frsky_settings frsky,
uint32_t *  value,
bool  test_presence_only,
uint32_t  arg 
)

Encode battery current value

Parameters
[out]valueencoded value
[in]test_presence_onlytrue when function should only test for availability of this value
[in]argargument specified in frsky_value_items[]
Returns
true when value succesfully encoded or presence test passed

Definition at line 131 of file frsky_packing.c.

bool frsky_encode_fuel ( struct frsky_settings frsky,
uint32_t *  value,
bool  test_presence_only,
uint32_t  arg 
)

Encode consumed battery energy as fuel

Parameters
[out]valueencoded value
[in]test_presence_onlytrue when function should only test for availability of this value
[in]argargument specified in frsky_value_items[]
Returns
true when value succesfully encoded or presence test passed

Definition at line 271 of file frsky_packing.c.

bool frsky_encode_gps_alt ( struct frsky_settings frsky,
uint32_t *  value,
bool  test_presence_only,
uint32_t  arg 
)

Encode gps altitude

Parameters
[out]valueencoded value
[in]test_presence_onlytrue when function should only test for availability of this value
[in]argargument specified in frsky_value_items[]
Returns
true when value succesfully encoded or presence test passed

Definition at line 448 of file frsky_packing.c.

bool frsky_encode_gps_coord ( struct frsky_settings frsky,
uint32_t *  value,
bool  test_presence_only,
uint32_t  arg 
)

Encode gps coordinates

Parameters
[out]valueencoded value
[in]test_presence_onlytrue when function should only test for availability of this value
[in]argargument specified in frsky_value_items[]; 0=lattitude, 1=longitude
Returns
true when value succesfully encoded or presence test passed

Definition at line 407 of file frsky_packing.c.

bool frsky_encode_gps_course ( struct frsky_settings frsky,
uint32_t *  value,
bool  test_presence_only,
uint32_t  arg 
)

Encode heading value

Parameters
[out]valueencoded value
[in]test_presence_onlytrue when function should only test for availability of this value
[in]argargument specified in frsky_value_items[]
Returns
true when value succesfully encoded or presence test passed

Definition at line 85 of file frsky_packing.c.

bool frsky_encode_gps_speed ( struct frsky_settings frsky,
uint32_t *  value,
bool  test_presence_only,
uint32_t  arg 
)

Encode gps speed

Parameters
[out]valueencoded value
[in]test_presence_onlytrue when function should only test for availability of this value
[in]argargument specified in frsky_value_items[]
Returns
true when value succesfully encoded or presence test passed

Definition at line 471 of file frsky_packing.c.

bool frsky_encode_gps_time ( struct frsky_settings frsky,
uint32_t *  value,
bool  test_presence_only,
uint32_t  arg 
)

Encode GPS UTC time

Parameters
[out]valueencoded value
[in]test_presence_onlytrue when function should only test for availability of this value
[in]argargument specified in frsky_value_items[]; 0=date, 1=time
Returns
true when value succesfully encoded or presence test passed

Definition at line 493 of file frsky_packing.c.

bool frsky_encode_rpm ( struct frsky_settings frsky,
uint32_t *  value,
bool  test_presence_only,
uint32_t  arg 
)

Encodes ARM status and flight mode number as RPM value Since there is no RPM information in any UAVO available, we will intentionaly misuse this item to encode another useful information. It will encode flight status as three-digit number as follow: most left digit encodes arm status (1=armed, 0=disarmed) two most right digits encodes flight mode number (see FlightStatus UAVO FlightMode enum) To work this propperly on Taranis, you have to set Blades to "1" in telemetry setting

Parameters
[out]valueencoded value
[in]test_presence_onlytrue when function should only test for availability of this value
[in]argargument specified in frsky_value_items[]
Returns
true when value succesfully encoded or presence test passed

Definition at line 536 of file frsky_packing.c.

bool frsky_encode_t1 ( struct frsky_settings frsky,
uint32_t *  value,
bool  test_presence_only,
uint32_t  arg 
)

Encode GPS status as T1 value Right-most two digits means visible satellite count, left-most digit has following meaning: 1 - no GPS connected 2 - no fix 3 - 2D fix 4 - 3D fix 5 - 3D fix and HomeLocation is SET - should be safe for navigation

Parameters
[out]valueencoded value
[in]test_presence_onlytrue when function should only test for availability of this value
[in]argargument specified in frsky_value_items[]
Returns
true when value successfully encoded or presence test passed

Definition at line 192 of file frsky_packing.c.

bool frsky_encode_t2 ( struct frsky_settings frsky,
uint32_t *  value,
bool  test_presence_only,
uint32_t  arg 
)

Encode GPS hDop and vDop as T2 Bits 0-7 = hDop * 100, max 255 (hDop = 2.55) Bits 8-15 = vDop * 100, max 255 (vDop = 2.55)

Parameters
[out]valueencoded value
[in]test_presence_onlytrue when function should only test for availability of this value
[in]argargument specified in frsky_value_items[]
Returns
true when value successfully encoded or presence test passed

Definition at line 241 of file frsky_packing.c.

bool frsky_encode_vario ( struct frsky_settings frsky,
uint32_t *  value,
bool  test_presence_only,
uint32_t  arg 
)

Encode vertical speed value

Parameters
[out]valueencoded value
[in]test_presence_onlytrue when function should only test for availability of this value
[in]argargument specified in frsky_value_items[]
Returns
true when value succesfully encoded or presence test passed

Definition at line 108 of file frsky_packing.c.

uint8_t frsky_insert_byte ( uint8_t *  obuff,
uint16_t *  chk,
uint8_t  byte 
)

Performs byte stuffing and checksum calculation

Parameters
[out]obuffbuffer where byte stuffed data will came in
[in,out]chkchecksum byte to update
[in]byte
Returns
count of bytes inserted to obuff (1 or 2)

Definition at line 581 of file frsky_packing.c.

int32_t frsky_send_frame ( uintptr_t  com,
enum frsky_value_id  id,
uint32_t  value,
bool  send_prelude 
)

Send u32 value dataframe to FrSky SmartPort bus

Parameters
[in]idFrSky value ID
[in]valuevalue

Definition at line 603 of file frsky_packing.c.