uORB: PublicationMulti get_instance() advertise if not already advertised

- fixes UAVCANv0 sensor bridge uORB usage, but also a reason thing to do in general
This commit is contained in:
Daniel Agar
2021-02-26 10:05:43 -05:00
parent 33d12db580
commit f1f396e338

View File

@@ -92,9 +92,10 @@ public:
return (orb_publish(get_topic(), _handle, &data) == PX4_OK); return (orb_publish(get_topic(), _handle, &data) == PX4_OK);
} }
int get_instance() const int get_instance()
{ {
if (_handle) { // advertise if not already advertised
if (advertise()) {
return static_cast<uORB::DeviceNode *>(_handle)->get_instance(); return static_cast<uORB::DeviceNode *>(_handle)->get_instance();
} }