mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-23 07:00:49 +08:00
* fix(dataman_client): keep request topic advertised on client teardown * fix(uorb): keep shared topics advertised on publisher teardown Single-instance publications share one advertised flag, so destroying one publisher must not hide updates from the others. Keep automatic unadvertising in PublicationMultiBase and remove the DatamanClient workaround. Cover surviving publishers and instance reuse, and reset retained input samples between test cases. Tested: make tests (215/215), make format. Signed-off-by: jonas <jonas.perolini@rigi.tech> Assisted-by: Codex * docs(uorb): correct unadvertise comments and document teardown The unadvertise comment claimed it has no effect on single-instance topics, which is how one publisher's teardown came to hide the others. State what clearing the shared flag does, and document that only PublicationMulti releases its instance on destruction. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: jonas <jonas.perolini@rigi.tech> * test(uorb): keep test cases independent of retained samples A destroyed single-instance publication now leaves its last sample visible, so ManualControlTest, test_prec_takeoff and mixer_module_tests passed only in declaration order and failed under --gtest_shuffle. Reset with an inert sample where one exists, otherwise unadvertise the test's own publications, and drop module outputs left over from a previous case. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: jonas <jonas.perolini@rigi.tech> * fix(boards): drop the PublicationBase destructor from the ITCM lists The destructor is now trivial and no longer emitted, so itcm_check.py fails on the missing section. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com> --------- Signed-off-by: jonas <jonas.perolini@rigi.tech> Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com> Co-authored-by: jonas <jonas.perolini@rigi.tech> Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
131 lines
3.5 KiB
C++
131 lines
3.5 KiB
C++
/****************************************************************************
|
|
*
|
|
* Copyright (c) 2019 PX4 Development Team. All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
*
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in
|
|
* the documentation and/or other materials provided with the
|
|
* distribution.
|
|
* 3. Neither the name PX4 nor the names of its contributors may be
|
|
* used to endorse or promote products derived from this software
|
|
* without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
*
|
|
****************************************************************************/
|
|
|
|
/**
|
|
* @file PublicationMulti.hpp
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <px4_platform_common/defines.h>
|
|
#include <systemlib/err.h>
|
|
#include <uORB/uORB.h>
|
|
#include "uORBDeviceNode.hpp"
|
|
|
|
#include "Publication.hpp"
|
|
|
|
namespace uORB
|
|
{
|
|
|
|
/**
|
|
* Base publication multi wrapper class
|
|
*/
|
|
class PublicationMultiBase : public PublicationBase
|
|
{
|
|
public:
|
|
bool advertise();
|
|
|
|
int get_instance();
|
|
|
|
protected:
|
|
PublicationMultiBase(ORB_ID id) :
|
|
PublicationBase(id)
|
|
{}
|
|
|
|
~PublicationMultiBase();
|
|
|
|
// type-independent publish; data points to a message of the topic's type
|
|
bool publish(const void *data);
|
|
};
|
|
|
|
/**
|
|
* Publication multi wrapper class
|
|
*/
|
|
template<typename T>
|
|
class PublicationMulti : public PublicationMultiBase
|
|
{
|
|
public:
|
|
|
|
/**
|
|
* Constructor
|
|
*
|
|
* @param meta The uORB metadata (usually from the ORB_ID() macro) for the topic.
|
|
*/
|
|
PublicationMulti(ORB_ID id) :
|
|
PublicationMultiBase(id)
|
|
{}
|
|
|
|
PublicationMulti(const orb_metadata *meta) :
|
|
PublicationMultiBase(static_cast<ORB_ID>(meta->o_id))
|
|
{}
|
|
|
|
/**
|
|
* Publish the struct
|
|
* @param data The uORB message struct we are updating.
|
|
*/
|
|
bool publish(const T &data) { return PublicationMultiBase::publish(&data); }
|
|
};
|
|
|
|
/**
|
|
* The publication multi class with data embedded.
|
|
*/
|
|
template<typename T>
|
|
class PublicationMultiData : public PublicationMulti<T>
|
|
{
|
|
public:
|
|
/**
|
|
* Constructor
|
|
*
|
|
* @param meta The uORB metadata (usually from the ORB_ID() macro) for the topic.
|
|
*/
|
|
PublicationMultiData(ORB_ID id) : PublicationMulti<T>(id) {}
|
|
PublicationMultiData(const orb_metadata *meta) : PublicationMulti<T>(meta) {}
|
|
|
|
T &get() { return _data; }
|
|
void set(const T &data) { _data = data; }
|
|
|
|
// Publishes the embedded struct.
|
|
bool update() { return PublicationMulti<T>::publish(_data); }
|
|
bool update(const T &data)
|
|
{
|
|
_data = data;
|
|
return PublicationMulti<T>::publish(_data);
|
|
}
|
|
|
|
private:
|
|
T _data{};
|
|
};
|
|
|
|
} // namespace uORB
|