Skip to content

Commit

Permalink
rc drivers: fix RC_TYPE magic numbers with vehicleCommand constants
Browse files Browse the repository at this point in the history
  • Loading branch information
benjinne committed Dec 16, 2024
1 parent 33781a0 commit 1336fb2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions msg/versioned/VehicleCommand.msg
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ uint8 ORBIT_YAW_BEHAVIOUR_HOLD_FRONT_TANGENT_TO_CIRCLE = 3
uint8 ORBIT_YAW_BEHAVIOUR_RC_CONTROLLED = 4
uint8 ORBIT_YAW_BEHAVIOUR_UNCHANGED = 5

# used as param1&2 in CMD_START_RX_PAIR
uint8 RC_TYPE_SPEKTRUM = 0
uint8 RC_TYPE_CRSF = 1
uint8 RC_SUB_TYPE_SPEKTRUM_DSM2 = 0
uint8 RC_SUB_TYPE_SPEKTRUM_DSMX = 1
uint8 RC_SUB_TYPE_SPEKTRUM_DSMX8 = 2

# used as param1 in ARM_DISARM command
int8 ARMING_ACTION_DISARM = 0
int8 ARMING_ACTION_ARM = 1
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/rc/crsf_rc/CrsfRc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void CrsfRc::Run()
uint8_t cmd_ret = vehicle_command_ack_s::VEHICLE_CMD_RESULT_UNSUPPORTED;

if (!_is_singlewire && !_armed) {
if ((int)vcmd.param1 == 1) {
if ((int)vcmd.param1 == vehicle_command_s::RC_TYPE_CRSF) {
// CRSF binding command
if (BindCRSF()) {
cmd_ret = vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED;
Expand Down
8 changes: 4 additions & 4 deletions src/drivers/rc_input/RCInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,19 +374,19 @@ void RCInput::Run()
#if defined(SPEKTRUM_POWER)

if (!_rc_scan_locked && !_armed) {
if ((int)vcmd.param1 == 0) {
if ((int)vcmd.param1 == vehicle_command_s::RC_TYPE_SPEKTRUM) {
// DSM binding command
int dsm_bind_mode = (int)vcmd.param2;

int dsm_bind_pulses = 0;

if (dsm_bind_mode == 0) {
if (dsm_bind_mode == vehicle_command_s::RC_SUB_TYPE_SPEKTRUM_DSM2) {
dsm_bind_pulses = DSM2_BIND_PULSES;

} else if (dsm_bind_mode == 1) {
} else if (dsm_bind_mode == vehicle_command_s::RC_SUB_TYPE_SPEKTRUM_DSMX) {
dsm_bind_pulses = DSMX_BIND_PULSES;

} else {
} else if (dsm_bind_mode == vehicle_command_s::RC_SUB_TYPE_SPEKTRUM_DSMX8) {
dsm_bind_pulses = DSMX8_BIND_PULSES;
}

Expand Down

0 comments on commit 1336fb2

Please sign in to comment.