mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-23 17:18:28 -04:00
AP_RCProtocol: support FPort RSSI
This commit is contained in:
parent
6447cc2519
commit
a72eaabc96
@ -257,6 +257,14 @@ uint16_t AP_RCProtocol::read(uint8_t chan)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t AP_RCProtocol::get_RSSI(void) const
|
||||||
|
{
|
||||||
|
if (_detected_protocol != AP_RCProtocol::NONE) {
|
||||||
|
return backend[_detected_protocol]->get_RSSI();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ask for bind start on supported receivers (eg spektrum satellite)
|
ask for bind start on supported receivers (eg spektrum satellite)
|
||||||
*/
|
*/
|
||||||
|
@ -63,6 +63,7 @@ public:
|
|||||||
uint16_t read(uint8_t chan);
|
uint16_t read(uint8_t chan);
|
||||||
bool new_input();
|
bool new_input();
|
||||||
void start_bind(void);
|
void start_bind(void);
|
||||||
|
int16_t get_RSSI(void) const;
|
||||||
|
|
||||||
// return protocol name as a string
|
// return protocol name as a string
|
||||||
static const char *protocol_name_from_protocol(rcprotocol_t protocol);
|
static const char *protocol_name_from_protocol(rcprotocol_t protocol);
|
||||||
|
@ -49,7 +49,7 @@ uint16_t AP_RCProtocol_Backend::read(uint8_t chan)
|
|||||||
/*
|
/*
|
||||||
provide input from a backend
|
provide input from a backend
|
||||||
*/
|
*/
|
||||||
void AP_RCProtocol_Backend::add_input(uint8_t num_values, uint16_t *values, bool in_failsafe)
|
void AP_RCProtocol_Backend::add_input(uint8_t num_values, uint16_t *values, bool in_failsafe, int16_t _rssi)
|
||||||
{
|
{
|
||||||
num_values = MIN(num_values, MAX_RCIN_CHANNELS);
|
num_values = MIN(num_values, MAX_RCIN_CHANNELS);
|
||||||
memcpy(_pwm_values, values, num_values*sizeof(uint16_t));
|
memcpy(_pwm_values, values, num_values*sizeof(uint16_t));
|
||||||
@ -63,4 +63,5 @@ void AP_RCProtocol_Backend::add_input(uint8_t num_values, uint16_t *values, bool
|
|||||||
if (!in_failsafe) {
|
if (!in_failsafe) {
|
||||||
rc_input_count++;
|
rc_input_count++;
|
||||||
}
|
}
|
||||||
|
rssi = _rssi;
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,13 @@ public:
|
|||||||
return rc_input_count;
|
return rc_input_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get RSSI
|
||||||
|
int16_t get_RSSI(void) const {
|
||||||
|
return rssi;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void add_input(uint8_t num_channels, uint16_t *values, bool in_failsafe);
|
void add_input(uint8_t num_channels, uint16_t *values, bool in_failsafe, int16_t rssi=-1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AP_RCProtocol &frontend;
|
AP_RCProtocol &frontend;
|
||||||
@ -62,4 +67,5 @@ private:
|
|||||||
|
|
||||||
uint16_t _pwm_values[MAX_RCIN_CHANNELS];
|
uint16_t _pwm_values[MAX_RCIN_CHANNELS];
|
||||||
uint8_t _num_channels;
|
uint8_t _num_channels;
|
||||||
|
int16_t rssi = -1;
|
||||||
};
|
};
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AP_RCProtocol_FPort.h"
|
#include "AP_RCProtocol_FPort.h"
|
||||||
|
#include <AP_Vehicle/AP_Vehicle_Type.h>
|
||||||
|
|
||||||
#define FRAME_HEAD 0x7E
|
#define FRAME_HEAD 0x7E
|
||||||
#define FRAME_LEN_CONTROL 0x19
|
#define FRAME_LEN_CONTROL 0x19
|
||||||
@ -104,7 +105,7 @@ void AP_RCProtocol_FPort::decode_control(const FPort_Frame &frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool failsafe = ((frame.control.flags & (1 << FLAGS_FAILSAFE_BIT)) != 0);
|
bool failsafe = ((frame.control.flags & (1 << FLAGS_FAILSAFE_BIT)) != 0);
|
||||||
add_input(MAX_CHANNELS, values, failsafe);
|
add_input(MAX_CHANNELS, values, failsafe, frame.control.rssi);
|
||||||
}
|
}
|
||||||
|
|
||||||
// decode a full FPort downlink frame
|
// decode a full FPort downlink frame
|
||||||
|
Loading…
Reference in New Issue
Block a user