mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 19:03:33 +08:00
Added PPM frame length feedback in IO comms and status command - allows to warn users about badly formatted PPM frames
This commit is contained in:
@@ -1724,6 +1724,16 @@ PX4IO::print_status()
|
|||||||
printf(" %u", io_reg_get(PX4IO_PAGE_RAW_RC_INPUT, PX4IO_P_RAW_RC_BASE + i));
|
printf(" %u", io_reg_get(PX4IO_PAGE_RAW_RC_INPUT, PX4IO_P_RAW_RC_BASE + i));
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
if (raw_inputs > 0) {
|
||||||
|
int frame_len = io_reg_get(PX4IO_PAGE_STATUS, PX4IO_P_STATUS_RC_DATA);
|
||||||
|
printf("RC data (PPM frame len) %u us\n", frame_len);
|
||||||
|
|
||||||
|
if ((frame_len - raw_inputs * 2000 - 3000) < 0) {
|
||||||
|
printf("WARNING WARNING WARNING! This RC receiver does not allow safe frame detection.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t mapped_inputs = io_reg_get(PX4IO_PAGE_RC_INPUT, PX4IO_P_RC_VALID);
|
uint16_t mapped_inputs = io_reg_get(PX4IO_PAGE_RC_INPUT, PX4IO_P_RC_VALID);
|
||||||
printf("mapped R/C inputs 0x%04x", mapped_inputs);
|
printf("mapped R/C inputs 0x%04x", mapped_inputs);
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
#define RC_CHANNEL_HIGH_THRESH 5000
|
#define RC_CHANNEL_HIGH_THRESH 5000
|
||||||
#define RC_CHANNEL_LOW_THRESH -5000
|
#define RC_CHANNEL_LOW_THRESH -5000
|
||||||
|
|
||||||
static bool ppm_input(uint16_t *values, uint16_t *num_values);
|
static bool ppm_input(uint16_t *values, uint16_t *num_values, uint16_t *frame_len);
|
||||||
|
|
||||||
static perf_counter_t c_gather_dsm;
|
static perf_counter_t c_gather_dsm;
|
||||||
static perf_counter_t c_gather_sbus;
|
static perf_counter_t c_gather_sbus;
|
||||||
@@ -125,7 +125,7 @@ controls_tick() {
|
|||||||
* disable the PPM decoder completely if we have S.bus signal.
|
* disable the PPM decoder completely if we have S.bus signal.
|
||||||
*/
|
*/
|
||||||
perf_begin(c_gather_ppm);
|
perf_begin(c_gather_ppm);
|
||||||
bool ppm_updated = ppm_input(r_raw_rc_values, &r_raw_rc_count);
|
bool ppm_updated = ppm_input(r_raw_rc_values, &r_raw_rc_count, &r_page_status[PX4IO_P_STATUS_RC_DATA]);
|
||||||
if (ppm_updated) {
|
if (ppm_updated) {
|
||||||
|
|
||||||
/* XXX sample RSSI properly here */
|
/* XXX sample RSSI properly here */
|
||||||
@@ -319,7 +319,7 @@ controls_tick() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
ppm_input(uint16_t *values, uint16_t *num_values)
|
ppm_input(uint16_t *values, uint16_t *num_values, uint16_t *frame_len)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
@@ -343,6 +343,10 @@ ppm_input(uint16_t *values, uint16_t *num_values)
|
|||||||
/* clear validity */
|
/* clear validity */
|
||||||
ppm_last_valid_decode = 0;
|
ppm_last_valid_decode = 0;
|
||||||
|
|
||||||
|
/* store PPM frame length */
|
||||||
|
if (num_values)
|
||||||
|
*frame_len = ppm_frame_length;
|
||||||
|
|
||||||
/* good if we got any channels */
|
/* good if we got any channels */
|
||||||
result = (*num_values > 0);
|
result = (*num_values > 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,8 @@
|
|||||||
#define PX4IO_P_STATUS_VSERVO 6 /* [2] servo rail voltage in mV */
|
#define PX4IO_P_STATUS_VSERVO 6 /* [2] servo rail voltage in mV */
|
||||||
#define PX4IO_P_STATUS_VRSSI 7 /* [2] RSSI voltage */
|
#define PX4IO_P_STATUS_VRSSI 7 /* [2] RSSI voltage */
|
||||||
#define PX4IO_P_STATUS_PRSSI 8 /* [2] RSSI PWM value */
|
#define PX4IO_P_STATUS_PRSSI 8 /* [2] RSSI PWM value */
|
||||||
#define PX4IO_P_STATUS_NRSSI 9 /* [2] Normalized RSSI value, 0: no reception, 1000: perfect reception */
|
#define PX4IO_P_STATUS_NRSSI 9 /* [2] Normalized RSSI value, 0: no reception, 255: perfect reception */
|
||||||
|
#define PX4IO_P_STATUS_RC_DATA 10 /* [1] + [2] Details about the RC source (PPM frame length, Spektrum protocol type) */
|
||||||
|
|
||||||
/* array of post-mix actuator outputs, -10000..10000 */
|
/* array of post-mix actuator outputs, -10000..10000 */
|
||||||
#define PX4IO_PAGE_ACTUATORS 2 /* 0..CONFIG_ACTUATOR_COUNT-1 */
|
#define PX4IO_PAGE_ACTUATORS 2 /* 0..CONFIG_ACTUATOR_COUNT-1 */
|
||||||
|
|||||||
@@ -89,7 +89,9 @@ uint16_t r_page_status[] = {
|
|||||||
[PX4IO_P_STATUS_IBATT] = 0,
|
[PX4IO_P_STATUS_IBATT] = 0,
|
||||||
[PX4IO_P_STATUS_VSERVO] = 0,
|
[PX4IO_P_STATUS_VSERVO] = 0,
|
||||||
[PX4IO_P_STATUS_VRSSI] = 0,
|
[PX4IO_P_STATUS_VRSSI] = 0,
|
||||||
[PX4IO_P_STATUS_PRSSI] = 0
|
[PX4IO_P_STATUS_PRSSI] = 0,
|
||||||
|
[PX4IO_P_STATUS_NRSSI] = 0,
|
||||||
|
[PX4IO_P_STATUS_RC_DATA] = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,7 +116,7 @@ uint16_t r_page_servos[PX4IO_SERVO_COUNT];
|
|||||||
uint16_t r_page_raw_rc_input[] =
|
uint16_t r_page_raw_rc_input[] =
|
||||||
{
|
{
|
||||||
[PX4IO_P_RAW_RC_COUNT] = 0,
|
[PX4IO_P_RAW_RC_COUNT] = 0,
|
||||||
[PX4IO_P_RAW_RC_BASE ... (PX4IO_P_RAW_RC_BASE + 24)] = 0 // XXX ensure we have enough space to decode beefy RX, will be replaced by patch soon
|
[PX4IO_P_RAW_RC_BASE ... (PX4IO_P_RAW_RC_BASE + PX4IO_CONTROL_CHANNELS)] = 0 // XXX ensure we have enough space to decode beefy RX, will be replaced by patch soon
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user