CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Frsky_Telem/AP_Frsky_MAVlite_Message.h
Views: 1798
1
#pragma once
2
3
#include "AP_Frsky_MAVlite.h"
4
5
#include <AP_Common/AP_Common.h>
6
7
#include <stdint.h>
8
9
#if HAL_WITH_FRSKY_TELEM_BIDIRECTIONAL
10
class AP_Frsky_MAVlite_Message {
11
public:
12
// helpers
13
bool get_float(float &value, const uint8_t offset) const WARN_IF_UNUSED {
14
return get_bytes((uint8_t*)&value, offset, 4);
15
}
16
bool set_float(const float value, const uint8_t offset) WARN_IF_UNUSED {
17
return set_bytes((uint8_t*)&value, offset, 4);
18
}
19
20
bool get_string(char* value, const uint8_t offset) const WARN_IF_UNUSED;
21
bool set_string(const char* value, const uint8_t offset) WARN_IF_UNUSED;
22
23
bool get_uint16(uint16_t &value, const uint8_t offset) const WARN_IF_UNUSED {
24
return get_bytes((uint8_t*)&value, offset, 2);
25
}
26
bool set_uint16(const uint16_t value, const uint8_t offset) WARN_IF_UNUSED {
27
return set_bytes((uint8_t*)&value, offset, 2);
28
}
29
30
bool get_uint8(uint8_t &value, const uint8_t offset) const WARN_IF_UNUSED {
31
return get_bytes((uint8_t*)&value, offset, 1);
32
}
33
bool set_uint8(const uint8_t value, const uint8_t offset) WARN_IF_UNUSED {
34
return set_bytes((uint8_t*)&value, offset, 1);
35
}
36
37
uint8_t msgid = 0; // ID of message in payload
38
uint8_t len = 0; // Length of payload
39
uint8_t payload[MAVLITE_MAX_PAYLOAD_LEN];
40
41
static void bit8_pack(uint8_t &value, const uint8_t bit_value, const uint8_t bit_count, const uint8_t bit_offset);
42
static uint8_t bit8_unpack(const uint8_t value, const uint8_t bit_count, const uint8_t bit_offset);
43
44
private:
45
bool get_bytes(uint8_t *bytes, const uint8_t offset, const uint8_t count) const WARN_IF_UNUSED;
46
bool set_bytes(const uint8_t *bytes, const uint8_t offset, const uint8_t count) WARN_IF_UNUSED;
47
};
48
#endif
49