diff --git a/libraries/AP_RPM/AP_RPM.cpp b/libraries/AP_RPM/AP_RPM.cpp index ef0061553e..adb9bc62cd 100644 --- a/libraries/AP_RPM/AP_RPM.cpp +++ b/libraries/AP_RPM/AP_RPM.cpp @@ -304,6 +304,18 @@ void AP_RPM::Log_RPM() const } #endif +#ifdef HAL_PERIPH_ENABLE_RPM_STREAM +// Return the sensor id to use for streaming over DroneCAN, negative number disables +int8_t AP_RPM::get_dronecan_sensor_id(uint8_t instance) const +{ + if (!enabled(instance)) { + return -1; + } + return _params[instance].dronecan_sensor_id; +} +#endif + + // singleton instance AP_RPM *AP_RPM::_singleton; diff --git a/libraries/AP_RPM/AP_RPM.h b/libraries/AP_RPM/AP_RPM.h index 6a6b0e4817..bb5b5b4612 100644 --- a/libraries/AP_RPM/AP_RPM.h +++ b/libraries/AP_RPM/AP_RPM.h @@ -104,6 +104,11 @@ public: // check settings are valid bool arming_checks(size_t buflen, char *buffer) const; +#ifdef HAL_PERIPH_ENABLE_RPM_STREAM + // Return the sensor id to use for streaming over DroneCAN, negative number disables + int8_t get_dronecan_sensor_id(uint8_t instance) const; +#endif + private: void convert_params(void); diff --git a/libraries/AP_RPM/AP_RPM_Params.cpp b/libraries/AP_RPM/AP_RPM_Params.cpp index 1d58d41eb6..1d9ed86d64 100644 --- a/libraries/AP_RPM/AP_RPM_Params.cpp +++ b/libraries/AP_RPM/AP_RPM_Params.cpp @@ -78,6 +78,16 @@ const AP_Param::GroupInfo AP_RPM_Params::var_info[] = { AP_GROUPINFO("ESC_INDEX", 8, AP_RPM_Params, esc_telem_outbound_index, 0), #endif +#ifdef HAL_PERIPH_ENABLE_RPM_STREAM + // @Param: DC_SEND_ID + // @DisplayName: DroneCAN Sensor ID + // @Description: DroneCAN sensor ID to send as on AP-Periph -1 disables + // @Range: -1 10 + // @Increment: 1 + // @User: Advanced + AP_GROUPINFO("DC_SEND_ID", 9, AP_RPM_Params, dronecan_sensor_id, -1), +#endif + AP_GROUPEND }; diff --git a/libraries/AP_RPM/AP_RPM_Params.h b/libraries/AP_RPM/AP_RPM_Params.h index 591bd76e7f..194fb464c3 100644 --- a/libraries/AP_RPM/AP_RPM_Params.h +++ b/libraries/AP_RPM/AP_RPM_Params.h @@ -33,6 +33,9 @@ public: #if AP_RPM_ESC_TELEM_OUTBOUND_ENABLED AP_Int8 esc_telem_outbound_index; #endif +#ifdef HAL_PERIPH_ENABLE_RPM_STREAM + AP_Int8 dronecan_sensor_id; +#endif static const struct AP_Param::GroupInfo var_info[];