Extend the PCF8583 driver to support multiple instances (#19232)

* Add some restart events into pcf8583 driver

Co-authored-by: Vít Hanousek <vithanousek@seznam.cz>
This commit is contained in:
Roman Dvořák
2022-02-21 16:47:16 -05:00
committed by GitHub
co-authored by Vít Hanousek
parent 3c58932aff
commit 976c994156
7 changed files with 151 additions and 49 deletions
+1 -1
View File
@@ -83,7 +83,6 @@ void LoggedTopics::add_default_topics()
add_topic("position_setpoint_triplet", 200);
add_optional_topic("px4io_status");
add_topic("radio_status");
add_optional_topic("rpm", 500);
add_topic("rtl_time_estimate", 1000);
add_topic("safety");
add_topic("sensor_combined");
@@ -123,6 +122,7 @@ void LoggedTopics::add_default_topics()
add_topic_multi("control_allocator_status", 200, 2);
add_optional_topic_multi("rate_ctrl_status", 200, 2);
add_topic_multi("sensor_hygrometer", 500, 4);
add_optional_topic_multi("rpm", 200);
add_optional_topic_multi("telemetry_status", 1000, 4);
// EKF multi topics (currently max 9 estimators)
+13 -9
View File
@@ -49,29 +49,33 @@ public:
unsigned get_size() override
{
return _rpm_sub.advertised() ? (MAVLINK_MSG_ID_RAW_RPM_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES) : 0;
return _rpm_subs.advertised_count() * (MAVLINK_MSG_ID_RAW_RPM_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES);
}
private:
explicit MavlinkStreamRawRpm(Mavlink *mavlink) : MavlinkStream(mavlink) {}
uORB::Subscription _rpm_sub{ORB_ID(rpm)};
uORB::SubscriptionMultiArray<rpm_s> _rpm_subs{ORB_ID::rpm};
bool send() override
{
rpm_s rpm;
bool updated = false;
if (_rpm_sub.update(&rpm)) {
mavlink_raw_rpm_t msg{};
for (int i = 0; i < _rpm_subs.size(); i++) {
rpm_s rpm;
msg.frequency = rpm.indicated_frequency_rpm;
if (_rpm_subs[i].update(&rpm)) {
mavlink_raw_rpm_t msg{};
mavlink_msg_raw_rpm_send_struct(_mavlink->get_channel(), &msg);
msg.index = i;
msg.frequency = rpm.indicated_frequency_rpm;
return true;
mavlink_msg_raw_rpm_send_struct(_mavlink->get_channel(), &msg);
updated = true;
}
}
return false;
return updated;
}
};