Skip to content

Commit

Permalink
src: drivers: uavcan: move UAVCAN_ECU_MAXF and UAVCAN_ECU_FUELT fetch…
Browse files Browse the repository at this point in the history
… to init and make reboot required
  • Loading branch information
TSC21 committed Jun 17, 2024
1 parent 8b41bc0 commit 5fbc340
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/drivers/uavcan/sensors/fuel_tank_status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/drivers/uavcan/uavcan_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 5fbc340

Please sign in to comment.