Skip to content

Commit

Permalink
mavlink模块可以初步编译通过
Browse files Browse the repository at this point in the history
  • Loading branch information
ComerLater committed May 9, 2024
1 parent d9bb760 commit f497784
Show file tree
Hide file tree
Showing 68 changed files with 756 additions and 579 deletions.
6 changes: 3 additions & 3 deletions apps/estimator/ekf2/EKF2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ using matrix::Eulerf;
using matrix::Quatf;
using matrix::Vector3f;

pthread_mutex_t ekf2_module_mutex = PTHREAD_MUTEX_INITIALIZER;
static px4::atomic<EKF2 *> _objects[EKF2_MAX_INSTANCES]{};
pthread_mutex_t ekf2_module_mutex = PTHREAD_MUTEX_INITIALIZER;
static atomic<EKF2 *> _objects[EKF2_MAX_INSTANCES]{};
#if defined(CONFIG_EKF2_MULTI_INSTANCE)
static px4::atomic<EKF2Selector *> _ekf2_selector{nullptr};
static atomic<EKF2Selector *> _ekf2_selector{nullptr};
#endif // CONFIG_EKF2_MULTI_INSTANCE

EKF2::EKF2(bool multi_mode, const px4::wq_config_t &config, bool replay_mode) :
Expand Down
2 changes: 1 addition & 1 deletion apps/estimator/ekf2/EKF2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class EKF2 final : public ModuleParams, public WorkItemScheduled {
const bool _multi_mode;
int _instance{0};

px4::atomic_bool _task_should_exit{false};
atomic_bool _task_should_exit{false};

// time slip monitoring
uint64_t _integrated_time_us = 0; ///< integral of gyro delta time from start (uSec)
Expand Down
6 changes: 3 additions & 3 deletions apps/estimator/ekf2/EKF2Selector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ class EKF2Selector : public ModuleParams, public WorkItemScheduled {
bool _gyro_fault_detected{false};
bool _accel_fault_detected{false};

uint8_t _available_instances{0};
uint8_t _selected_instance{INVALID_INSTANCE};
px4::atomic<uint8_t> _request_instance{INVALID_INSTANCE};
uint8_t _available_instances{0};
uint8_t _selected_instance{INVALID_INSTANCE};
atomic<uint8_t> _request_instance{INVALID_INSTANCE};

uint32_t _instance_changed_count{0};
hrt_abstime _last_instance_change{0};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
class TemperatureCalibration;

namespace temperature_calibration {
px4::atomic<TemperatureCalibration *> instance{nullptr};
atomic<TemperatureCalibration *> instance{nullptr};
}

class TemperatureCalibration {
Expand Down
1 change: 1 addition & 0 deletions apps/libraries/telemetry/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
orsource "*/Kconfig"
18 changes: 18 additions & 0 deletions apps/libraries/telemetry/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os
import rtconfig
from building import *

cwd = GetCurrentDir()
objs = []


inc = [cwd]

objs += DefineGroup(name="lib/include", src=[], depend=[], CPPPATH=inc)

for d in os.listdir(cwd):
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, "SConscript")):
objs += SConscript(os.path.join(d, "SConscript"))

Return("objs")
7 changes: 4 additions & 3 deletions apps/libraries/telemetry/button/ButtonPublisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@

#include <drivers/drv_tone_alarm.h>
#include <hrtimer.h>
#include <uORB/Publication.hpp>
#include <uORB/PublicationMulti.hpp>
#include <uORB/Subscription.hpp>
#include <uORB/uORBPublication.hpp>
#include <uORB/uORBSubscription.hpp>
#include <uORB/topics/actuator_armed.h>
#include <uORB/topics/button_event.h>
#include <uORB/topics/vehicle_command.h>
#include <uORB/topics/led_control.h>
#include <uORB/topics/tune_control.h>

using namespace nextpilot;

class ButtonPublisher
{
public:
Expand Down
34 changes: 0 additions & 34 deletions apps/libraries/telemetry/button/CMakeLists.txt

This file was deleted.

3 changes: 3 additions & 0 deletions apps/libraries/telemetry/button/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
menuconfig PKG_USING_BUTTON_PUBLISHER
bool "Library for button functionality"
default n
16 changes: 16 additions & 0 deletions apps/libraries/telemetry/button/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
import rtconfig
from building import *


cwd = GetCurrentDir()

inc = []
src = Glob("*.cpp")

objs = DefineGroup(
"lib/timesync", src, depend=["PKG_USING_BUTTON_PUBLISHER"], CPPPATH=inc
)


Return("objs")
38 changes: 0 additions & 38 deletions apps/libraries/telemetry/timesync/CMakeLists.txt

This file was deleted.

3 changes: 3 additions & 0 deletions apps/libraries/telemetry/timesync/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
menuconfig PKG_USING_TIMESYNC
bool "time synchroniser definition"
default n
14 changes: 14 additions & 0 deletions apps/libraries/telemetry/timesync/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os
import rtconfig
from building import *


cwd = GetCurrentDir()

inc = []
src = Glob("*.cpp")

objs = DefineGroup("lib/timesync", src, depend=["PKG_USING_TIMESYNC"], CPPPATH=inc)


Return("objs")
3 changes: 2 additions & 1 deletion apps/libraries/telemetry/timesync/Timesync.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@

#include <hrtimer.h>

#include <uORB/PublicationMulti.hpp>
#include <uORB/uORBPublication.hpp>
#include <uORB/topics/timesync_status.h>

#include <math.h>
#include <float.h>

using namespace time_literals;
using namespace nextpilot;

static constexpr time_t PX4_EPOCH_SECS = 1234567890ULL;

Expand Down
4 changes: 2 additions & 2 deletions apps/peripheral/payload/gimbal/gimbal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
using namespace time_literals;
using namespace gimbal;

static px4::atomic<bool> thread_should_exit{false};
static px4::atomic<bool> thread_running{false};
static atomic<bool> thread_should_exit{false};
static atomic<bool> thread_running{false};

static constexpr int input_objs_len_max = 3;

Expand Down
2 changes: 1 addition & 1 deletion apps/peripheral/payload/gimbal/input_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class InputTest : public InputBase {
int _pitch_deg{0};
int _yaw_deg{0};

px4::atomic<bool> _has_been_set{false};
atomic<bool> _has_been_set{false};
};

} /* namespace gimbal */
2 changes: 1 addition & 1 deletion apps/simulation/gz_bridge/GZBridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class GZBridge : public ModuleCommand<GZBridge>, public ModuleParams, public Wor
GZMixingInterfaceESC _mixing_interface_esc{_node, _node_mutex};
GZMixingInterfaceServo _mixing_interface_servo{_node, _node_mutex};

px4::atomic<uint64_t> _world_time_us{0};
atomic<uint64_t> _world_time_us{0};

pthread_mutex_t _node_mutex;

Expand Down
2 changes: 1 addition & 1 deletion apps/simulation/simulator_mavlink/SimulatorMavlink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class SimulatorMavlink : public ModuleParams {
int32_t _output_functions[actuator_outputs_s::NUM_ACTUATOR_OUTPUTS]{};

#if defined(ENABLE_LOCKSTEP_SCHEDULER)
px4::atomic<bool> _has_initialized{false};
atomic<bool> _has_initialized{false};
#endif

int _lockstep_component{-1};
Expand Down
4 changes: 2 additions & 2 deletions apps/storage/replay/Replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void Replay::setUserParams(const char *filename) {
int32_t value = (int32_t)param_value_double;

if (orig_value != value) {
PX4_WARN("setting %s (INT32) %d -> %d", param_name(handle), orig_value, value);
PX4_WARN("setting %s (INT32) %d -> %d", param_get_name(handle), orig_value, value);
}

param_set(handle, (const void *)&value);
Expand All @@ -142,7 +142,7 @@ void Replay::setUserParams(const char *filename) {
float value = (float)param_value_double;

if (fabsf(orig_value - value) > FLT_EPSILON) {
PX4_WARN("setting %s (FLOAT) %.3f -> %.3f", param_name(handle), (double)orig_value, (double)value);
PX4_WARN("setting %s (FLOAT) %.3f -> %.3f", param_get_name(handle), (double)orig_value, (double)value);
}

param_set(handle, (const void *)&value);
Expand Down
6 changes: 6 additions & 0 deletions apps/telemetry/mavlink/Kconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
menuconfig TEL_USING_MAVLINK
bool "mavlink"
select PKG_USING_VAR_LEN_RINGBUFFER
default n
---help---
Enable support for mavlink
Expand All @@ -18,6 +19,11 @@ depends on TEL_USING_MAVLINK && TEL_USING_UAVCAN
---help---
Expose UAVCAN parameters over Mavlink.


config MAVLINK_USING_SHELL
bool "enable mavlink shell service"
default n

# menuconfig USER_MAVLINK
# bool "mavlink running as userspace module"
# default y
Expand Down
30 changes: 15 additions & 15 deletions apps/telemetry/mavlink/MavlinkStatustextHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ bool MavlinkStatustextHandler::should_publish_previous(const mavlink_statustext_
// happen if the last chunk has been dropped, let's publish what we have.
if (_last_log_id > 0 && msg_statustext.id != _last_log_id) {
// We add a note that a part is missing at the end.
const size_t offset = strlen(_log_msg.text);
strncpy(_log_msg.text + offset, "[ missing ... ]",
sizeof(_log_msg.text) - offset);
const size_t offset = rt_strlen(_log_msg.text);
rt_strncpy(_log_msg.text + offset, "[ missing ... ]",
sizeof(_log_msg.text) - offset);
_log_msg.text[sizeof(_log_msg.text) - 1] = '\0';

return true;
Expand All @@ -38,29 +38,29 @@ bool MavlinkStatustextHandler::should_publish_current(const mavlink_statustext_t

if (msg_statustext.chunk_seq == 0) {
// We start from 0 with a new message.
strncpy(_log_msg.text, msg_statustext.text,
math::min(sizeof(_log_msg.text), sizeof(msg_statustext.text)));
rt_strncpy(_log_msg.text, msg_statustext.text,
math::min(sizeof(_log_msg.text), sizeof(msg_statustext.text)));
_log_msg.text[sizeof(msg_statustext.text)] = '\0';

} else {
if (msg_statustext.chunk_seq != _last_log_chunk_seq + 1) {
const size_t offset = strlen(_log_msg.text);
strncpy(_log_msg.text + offset, "[ missing ... ]",
sizeof(_log_msg.text) - offset);
const size_t offset = rt_strlen(_log_msg.text);
rt_strncpy(_log_msg.text + offset, "[ missing ... ]",
sizeof(_log_msg.text) - offset);
_log_msg.text[sizeof(_log_msg.text) - offset - 1] = '\0';
}

// We add a consecutive chunk.
const size_t offset = strlen(_log_msg.text);
const size_t offset = rt_strlen(_log_msg.text);
const size_t max_to_add = math::min(sizeof(_log_msg.text) - offset - 1, sizeof(msg_statustext.text));
strncpy(_log_msg.text + offset, msg_statustext.text, max_to_add);
rt_strncpy(_log_msg.text + offset, msg_statustext.text, max_to_add);
_log_msg.text[math::min(offset + max_to_add, sizeof(_log_msg.text) - 1)] = '\0';
}

_last_log_chunk_seq = msg_statustext.chunk_seq;

const bool publication_message_is_full = sizeof(_log_msg.text) - 1 == strlen(_log_msg.text);
const bool found_zero_termination = strnlen(msg_statustext.text, sizeof(msg_statustext.text)) < sizeof(msg_statustext.text);
const bool publication_message_is_full = sizeof(_log_msg.text) - 1 == rt_strlen(_log_msg.text);
const bool found_zero_termination = rt_strnlen(msg_statustext.text, sizeof(msg_statustext.text)) < sizeof(msg_statustext.text);

if (publication_message_is_full || found_zero_termination) {
_last_log_id = 0;
Expand All @@ -80,9 +80,9 @@ bool MavlinkStatustextHandler::should_publish_current(const mavlink_statustext_t
static_assert(sizeof(_log_msg.text) > sizeof(msg_statustext.text),
"_log_msg.text not big enough to hold msg_statustext.text");

strncpy(_log_msg.text, msg_statustext.text,
math::min(sizeof(_log_msg.text),
sizeof(msg_statustext.text)));
rt_strncpy(_log_msg.text, msg_statustext.text,
math::min(sizeof(_log_msg.text),
sizeof(msg_statustext.text)));

// We need to 0-terminate after the copied text which does not have to be
// 0-terminated on the wire.
Expand Down
Loading

0 comments on commit f497784

Please sign in to comment.