mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 08:38:53 +08:00
src: drivers: uavcan: move UAVCAN_ECU_MAXF and UAVCAN_ECU_FUELT fetch to init and make reboot required
This commit is contained in:
@@ -57,6 +57,12 @@ int UavcanFuelTankStatusBridge::init()
|
||||
return res;
|
||||
}
|
||||
|
||||
// Fetch maximum fuel capacity (in liters)
|
||||
param_get(param_find("UAVCAN_ECU_MAXF"), &_max_fuel_capacity);
|
||||
|
||||
// Fetching fuel type
|
||||
param_get(param_find("UAVCAN_ECU_FUELT"), &_fuel_type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -65,16 +71,7 @@ void UavcanFuelTankStatusBridge::fuel_tank_status_sub_cb(const
|
||||
{
|
||||
auto report = ::fuel_tank_status_s();
|
||||
report.timestamp = hrt_absolute_time();
|
||||
|
||||
// Fetching maximum fuel capacity (in liters) from a parameter
|
||||
param_get(param_find("UAVCAN_ECU_MAXF"), &_max_fuel_capacity);
|
||||
|
||||
_max_fuel_capacity *= 1000.0f; // convert to ml
|
||||
report.maximum_fuel_capacity = _max_fuel_capacity;
|
||||
|
||||
// Fetching fuel type
|
||||
param_get(param_find("UAVCAN_ECU_FUELT"), &_fuel_type);
|
||||
|
||||
report.maximum_fuel_capacity = _max_fuel_capacity * 1000.0f; // convert to ml
|
||||
report.fuel_type = static_cast<uint8_t>(_fuel_type);
|
||||
report.consumed_fuel = NAN; // only the remaining fuel is measured
|
||||
report.fuel_consumption_rate = msg.fuel_consumption_rate_cm3pm / 60.0f; // convert to ml/s
|
||||
|
||||
@@ -107,6 +107,7 @@ PARAM_DEFINE_FLOAT(UAVCAN_RNG_MAX, 200.0f);
|
||||
* @unit liters
|
||||
* @decimal 1
|
||||
* @increment 0.1
|
||||
* @reboot_required true
|
||||
* @group UAVCAN
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(UAVCAN_ECU_MAXF, 15.0f);
|
||||
@@ -125,6 +126,7 @@ PARAM_DEFINE_FLOAT(UAVCAN_ECU_MAXF, 15.0f);
|
||||
* @value 0 Unknown
|
||||
* @value 1 Liquid
|
||||
* @value 2 Gas
|
||||
* @reboot_required true
|
||||
* @group UAVCAN
|
||||
*/
|
||||
PARAM_DEFINE_INT32(UAVCAN_ECU_FUELT, 1);
|
||||
|
||||
Reference in New Issue
Block a user