mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 03:49:12 +08:00
batt_smbus: switch to battery_info.serial_number
This commit is contained in:
committed by
Silvan Fuhrer
parent
d7ab21b8d6
commit
7895976a17
@@ -77,6 +77,7 @@ BATT_SMBUS::BATT_SMBUS(const I2CSPIDriverConfig &config, SMBus *interface) :
|
|||||||
|
|
||||||
BATT_SMBUS::~BATT_SMBUS()
|
BATT_SMBUS::~BATT_SMBUS()
|
||||||
{
|
{
|
||||||
|
orb_unadvertise(_battery_info_topic);
|
||||||
orb_unadvertise(_batt_topic);
|
orb_unadvertise(_batt_topic);
|
||||||
perf_free(_cycle);
|
perf_free(_cycle);
|
||||||
|
|
||||||
@@ -165,7 +166,6 @@ void BATT_SMBUS::RunImpl()
|
|||||||
if (ret == PX4_OK) {
|
if (ret == PX4_OK) {
|
||||||
new_report.capacity = _batt_capacity;
|
new_report.capacity = _batt_capacity;
|
||||||
new_report.cycle_count = _cycle_count;
|
new_report.cycle_count = _cycle_count;
|
||||||
new_report.serial_number = _serial_number;
|
|
||||||
new_report.max_cell_voltage_delta = _max_cell_voltage_delta;
|
new_report.max_cell_voltage_delta = _max_cell_voltage_delta;
|
||||||
new_report.cell_count = _cell_count;
|
new_report.cell_count = _cell_count;
|
||||||
new_report.state_of_health = _state_of_health;
|
new_report.state_of_health = _state_of_health;
|
||||||
@@ -192,6 +192,13 @@ void BATT_SMBUS::RunImpl()
|
|||||||
int instance = 0;
|
int instance = 0;
|
||||||
orb_publish_auto(ORB_ID(battery_status), &_batt_topic, &new_report, &instance);
|
orb_publish_auto(ORB_ID(battery_status), &_batt_topic, &new_report, &instance);
|
||||||
|
|
||||||
|
battery_info_s battery_info{};
|
||||||
|
battery_info.timestamp = new_report.timestamp;
|
||||||
|
battery_info.id = new_report.id;
|
||||||
|
snprintf(battery_info.serial_number, sizeof(battery_info.serial_number), "%" PRIu16, _serial_number);
|
||||||
|
orb_publish_auto(ORB_ID(battery_info), &_battery_info_topic, &battery_info, &instance);
|
||||||
|
|
||||||
|
|
||||||
_last_report = new_report;
|
_last_report = new_report;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
#include <px4_platform_common/param.h>
|
#include <px4_platform_common/param.h>
|
||||||
#include <px4_platform_common/getopt.h>
|
#include <px4_platform_common/getopt.h>
|
||||||
#include <px4_platform_common/i2c_spi_buses.h>
|
#include <px4_platform_common/i2c_spi_buses.h>
|
||||||
|
#include <uORB/topics/battery_info.h>
|
||||||
#include <uORB/topics/battery_status.h>
|
#include <uORB/topics/battery_status.h>
|
||||||
|
|
||||||
#include <board_config.h>
|
#include <board_config.h>
|
||||||
@@ -242,7 +243,7 @@ private:
|
|||||||
/** @param _last_report Last published report, used for test(). */
|
/** @param _last_report Last published report, used for test(). */
|
||||||
battery_status_s _last_report{};
|
battery_status_s _last_report{};
|
||||||
|
|
||||||
/** @param _batt_topic uORB battery topic. */
|
orb_advert_t _battery_info_topic{nullptr};
|
||||||
orb_advert_t _batt_topic{nullptr};
|
orb_advert_t _batt_topic{nullptr};
|
||||||
|
|
||||||
/** @param _cell_count Number of series cell. */
|
/** @param _cell_count Number of series cell. */
|
||||||
|
|||||||
Reference in New Issue
Block a user