mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 10:26:52 +08:00
Hotfix for S.Bus systems with more than 8 channels
This commit is contained in:
@@ -108,9 +108,11 @@ controls_tick() {
|
|||||||
perf_end(c_gather_dsm);
|
perf_end(c_gather_dsm);
|
||||||
|
|
||||||
perf_begin(c_gather_sbus);
|
perf_begin(c_gather_sbus);
|
||||||
bool sbus_updated = sbus_input(r_raw_rc_values, &r_raw_rc_count);
|
bool sbus_updated = sbus_input(r_raw_rc_values, &r_raw_rc_count, PX4IO_CONTROL_CHANNELS /* XXX this should be INPUT channels, once untangled */);
|
||||||
if (sbus_updated)
|
if (sbus_updated) {
|
||||||
r_status_flags |= PX4IO_P_STATUS_FLAGS_RC_SBUS;
|
r_status_flags |= PX4IO_P_STATUS_FLAGS_RC_SBUS;
|
||||||
|
r_raw_rc_count = 8;
|
||||||
|
}
|
||||||
perf_end(c_gather_sbus);
|
perf_end(c_gather_sbus);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
*/
|
*/
|
||||||
#define PX4IO_SERVO_COUNT 8
|
#define PX4IO_SERVO_COUNT 8
|
||||||
#define PX4IO_CONTROL_CHANNELS 8
|
#define PX4IO_CONTROL_CHANNELS 8
|
||||||
#define PX4IO_INPUT_CHANNELS 12
|
#define PX4IO_INPUT_CHANNELS 8 // XXX this should be 18 channels
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Debug logging
|
* Debug logging
|
||||||
@@ -200,7 +200,7 @@ extern int dsm_init(const char *device);
|
|||||||
extern bool dsm_input(uint16_t *values, uint16_t *num_values);
|
extern bool dsm_input(uint16_t *values, uint16_t *num_values);
|
||||||
extern void dsm_bind(uint16_t cmd, int pulses);
|
extern void dsm_bind(uint16_t cmd, int pulses);
|
||||||
extern int sbus_init(const char *device);
|
extern int sbus_init(const char *device);
|
||||||
extern bool sbus_input(uint16_t *values, uint16_t *num_values);
|
extern bool sbus_input(uint16_t *values, uint16_t *num_values, uint16_t max_channels);
|
||||||
|
|
||||||
/** global debug level for isr_debug() */
|
/** global debug level for isr_debug() */
|
||||||
extern volatile uint8_t debug_level;
|
extern volatile uint8_t debug_level;
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ static unsigned partial_frame_count;
|
|||||||
|
|
||||||
unsigned sbus_frame_drops;
|
unsigned sbus_frame_drops;
|
||||||
|
|
||||||
static bool sbus_decode(hrt_abstime frame_time, uint16_t *values, uint16_t *num_values);
|
static bool sbus_decode(hrt_abstime frame_time, uint16_t *values, uint16_t *num_values, uint16_t max_channels);
|
||||||
|
|
||||||
int
|
int
|
||||||
sbus_init(const char *device)
|
sbus_init(const char *device)
|
||||||
@@ -97,7 +97,7 @@ sbus_init(const char *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
sbus_input(uint16_t *values, uint16_t *num_values)
|
sbus_input(uint16_t *values, uint16_t *num_values, uint16_t max_channels)
|
||||||
{
|
{
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
hrt_abstime now;
|
hrt_abstime now;
|
||||||
@@ -154,7 +154,7 @@ sbus_input(uint16_t *values, uint16_t *num_values)
|
|||||||
* decode it.
|
* decode it.
|
||||||
*/
|
*/
|
||||||
partial_frame_count = 0;
|
partial_frame_count = 0;
|
||||||
return sbus_decode(now, values, num_values);
|
return sbus_decode(now, values, num_values, max_channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -194,7 +194,7 @@ static const struct sbus_bit_pick sbus_decoder[SBUS_INPUT_CHANNELS][3] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
sbus_decode(hrt_abstime frame_time, uint16_t *values, uint16_t *num_values)
|
sbus_decode(hrt_abstime frame_time, uint16_t *values, uint16_t *num_values, uint16_t max_values)
|
||||||
{
|
{
|
||||||
/* check frame boundary markers to avoid out-of-sync cases */
|
/* check frame boundary markers to avoid out-of-sync cases */
|
||||||
if ((frame[0] != 0x0f) || (frame[24] != 0x00)) {
|
if ((frame[0] != 0x0f) || (frame[24] != 0x00)) {
|
||||||
@@ -214,8 +214,8 @@ sbus_decode(hrt_abstime frame_time, uint16_t *values, uint16_t *num_values)
|
|||||||
/* we have received something we think is a frame */
|
/* we have received something we think is a frame */
|
||||||
last_frame_time = frame_time;
|
last_frame_time = frame_time;
|
||||||
|
|
||||||
unsigned chancount = (PX4IO_INPUT_CHANNELS > SBUS_INPUT_CHANNELS) ?
|
unsigned chancount = (max_values > SBUS_INPUT_CHANNELS) ?
|
||||||
SBUS_INPUT_CHANNELS : PX4IO_INPUT_CHANNELS;
|
SBUS_INPUT_CHANNELS : max_values;
|
||||||
|
|
||||||
/* use the decoder matrix to extract channel data */
|
/* use the decoder matrix to extract channel data */
|
||||||
for (unsigned channel = 0; channel < chancount; channel++) {
|
for (unsigned channel = 0; channel < chancount; channel++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user