mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-19 09:53:33 +08:00
drivers/modules: changes after mavlink_log change
The mavlink_log API changes lead to changes in all drivers/modules using it.
This commit is contained in:
@@ -51,6 +51,8 @@
|
||||
#include <systemlib/systemlib.h>
|
||||
#include <systemlib/err.h>
|
||||
#include <systemlib/param/param.h>
|
||||
#include <systemlib/mavlink_log.h>
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
#include <uORB/topics/camera_trigger.h>
|
||||
#include <uORB/topics/sensor_combined.h>
|
||||
@@ -59,7 +61,6 @@
|
||||
#include <poll.h>
|
||||
#include <drivers/drv_gpio.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <mavlink/mavlink_log.h>
|
||||
#include <board_config.h>
|
||||
|
||||
#define TRIGGER_PIN_DEFAULT 1
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
#include <systemlib/err.h>
|
||||
#include <arch/board/board.h>
|
||||
#include <mavlink/mavlink_log.h>
|
||||
#include <systemlib/mavlink_log.h>
|
||||
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/topics/debug_key_value.h>
|
||||
@@ -80,7 +80,7 @@ enum {
|
||||
};
|
||||
|
||||
// File descriptors
|
||||
static int mavlink_fd;
|
||||
static orb_advert_t mavlink_log_pub;
|
||||
|
||||
MD25::MD25(const char *deviceName, int bus,
|
||||
uint16_t address, uint32_t speed) :
|
||||
|
||||
@@ -2517,18 +2517,18 @@ void
|
||||
PX4FMU::dsm_bind_ioctl(int dsmMode)
|
||||
{
|
||||
if (!_armed.armed) {
|
||||
// mavlink_log_info(_mavlink_fd, "[FMU] binding DSM%s RX", (dsmMode == 0) ? "2" : ((dsmMode == 1) ? "-X" : "-X8"));
|
||||
// mavlink_log_info(&_mavlink_log_pub, "[FMU] binding DSM%s RX", (dsmMode == 0) ? "2" : ((dsmMode == 1) ? "-X" : "-X8"));
|
||||
warnx("[FMU] binding DSM%s RX", (dsmMode == 0) ? "2" : ((dsmMode == 1) ? "-X" : "-X8"));
|
||||
int ret = ioctl(nullptr, DSM_BIND_START,
|
||||
(dsmMode == 0) ? DSM2_BIND_PULSES : ((dsmMode == 1) ? DSMX_BIND_PULSES : DSMX8_BIND_PULSES));
|
||||
|
||||
if (ret) {
|
||||
// mavlink_log_critical(_mavlink_fd, "binding failed.");
|
||||
// mavlink_log_critical(&_mavlink_log_pub, "binding failed.");
|
||||
warnx("binding failed.");
|
||||
}
|
||||
|
||||
} else {
|
||||
// mavlink_log_info(_mavlink_fd, "[FMU] system armed, bind request rejected");
|
||||
// mavlink_log_info(&_mavlink_log_pub, "[FMU] system armed, bind request rejected");
|
||||
warnx("[FMU] system armed, bind request rejected");
|
||||
}
|
||||
}
|
||||
|
||||
+18
-25
@@ -73,6 +73,7 @@
|
||||
#include <systemlib/scheduling_priorities.h>
|
||||
#include <systemlib/param/param.h>
|
||||
#include <systemlib/circuit_breaker.h>
|
||||
#include <systemlib/mavlink_log.h>
|
||||
|
||||
#include <uORB/topics/actuator_controls.h>
|
||||
#include <uORB/topics/actuator_controls_0.h>
|
||||
@@ -92,7 +93,6 @@
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include <mavlink/mavlink_log.h>
|
||||
#include <modules/px4iofirmware/protocol.h>
|
||||
|
||||
#include "uploader.h"
|
||||
@@ -264,7 +264,7 @@ private:
|
||||
volatile int _task; ///< worker task id
|
||||
volatile bool _task_should_exit; ///< worker terminate flag
|
||||
|
||||
int _mavlink_fd; ///< mavlink file descriptor.
|
||||
orb_advert_t _mavlink_log_pub; ///< mavlink log pub
|
||||
|
||||
perf_counter_t _perf_update; ///< local performance counter for status updates
|
||||
perf_counter_t _perf_write; ///< local performance counter for PWM control writes
|
||||
@@ -505,7 +505,7 @@ PX4IO::PX4IO(device::Device *interface) :
|
||||
_rc_last_valid(0),
|
||||
_task(-1),
|
||||
_task_should_exit(false),
|
||||
_mavlink_fd(-1),
|
||||
_mavlink_log_pub(nullptr),
|
||||
_perf_update(perf_alloc(PC_ELAPSED, "io update")),
|
||||
_perf_write(perf_alloc(PC_ELAPSED, "io write")),
|
||||
_perf_sample_latency(perf_alloc(PC_ELAPSED, "io latency")),
|
||||
@@ -604,7 +604,7 @@ PX4IO::detect()
|
||||
|
||||
} else {
|
||||
DEVICE_LOG("IO version error");
|
||||
mavlink_log_emergency(_mavlink_fd, "IO VERSION MISMATCH, PLEASE UPGRADE SOFTWARE!");
|
||||
mavlink_log_emergency(&_mavlink_log_pub, "IO VERSION MISMATCH, PLEASE UPGRADE SOFTWARE!");
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -662,12 +662,12 @@ PX4IO::init()
|
||||
|
||||
/* if the error still persists after timing out, we give up */
|
||||
if (protocol == _io_reg_get_error) {
|
||||
mavlink_and_console_log_emergency(_mavlink_fd, "Failed to communicate with IO, abort.");
|
||||
mavlink_and_console_log_emergency(&_mavlink_log_pub, "Failed to communicate with IO, abort.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (protocol != PX4IO_PROTOCOL_VERSION) {
|
||||
mavlink_and_console_log_emergency(_mavlink_fd, "IO protocol/firmware mismatch, abort.");
|
||||
mavlink_and_console_log_emergency(&_mavlink_log_pub, "IO protocol/firmware mismatch, abort.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -684,7 +684,7 @@ PX4IO::init()
|
||||
(_max_rc_input < 1) || (_max_rc_input > 255)) {
|
||||
|
||||
DEVICE_LOG("config read error");
|
||||
mavlink_log_emergency(_mavlink_fd, "[IO] config read fail, abort.");
|
||||
mavlink_log_emergency(&_mavlink_log_pub, "[IO] config read fail, abort.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -722,7 +722,7 @@ PX4IO::init()
|
||||
/* get a status update from IO */
|
||||
io_get_status();
|
||||
|
||||
mavlink_and_console_log_emergency(_mavlink_fd, "RECOVERING FROM FMU IN-AIR RESTART");
|
||||
mavlink_and_console_log_emergency(&_mavlink_log_pub, "RECOVERING FROM FMU IN-AIR RESTART");
|
||||
|
||||
/* WARNING: COMMANDER app/vehicle status must be initialized.
|
||||
* If this fails (or the app is not started), worst-case IO
|
||||
@@ -751,7 +751,7 @@ PX4IO::init()
|
||||
|
||||
/* abort after 5s */
|
||||
if ((hrt_absolute_time() - try_start_time) / 1000 > 3000) {
|
||||
mavlink_and_console_log_emergency(_mavlink_fd, "Failed to recover from in-air restart (1), abort");
|
||||
mavlink_and_console_log_emergency(&_mavlink_log_pub, "Failed to recover from in-air restart (1), abort");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -807,7 +807,7 @@ PX4IO::init()
|
||||
|
||||
/* abort after 5s */
|
||||
if ((hrt_absolute_time() - try_start_time) / 1000 > 2000) {
|
||||
mavlink_and_console_log_emergency(_mavlink_fd, "Failed to recover from in-air restart (2), abort");
|
||||
mavlink_and_console_log_emergency(&_mavlink_log_pub, "Failed to recover from in-air restart (2), abort");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -854,7 +854,7 @@ PX4IO::init()
|
||||
ret = io_set_rc_config();
|
||||
|
||||
if (ret != OK) {
|
||||
mavlink_and_console_log_critical(_mavlink_fd, "IO RC config upload fail");
|
||||
mavlink_and_console_log_critical(&_mavlink_log_pub, "IO RC config upload fail");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -911,8 +911,6 @@ PX4IO::task_main()
|
||||
hrt_abstime poll_last = 0;
|
||||
hrt_abstime orb_check_last = 0;
|
||||
|
||||
_mavlink_fd = ::open(MAVLINK_LOG_DEVICE, 0);
|
||||
|
||||
/*
|
||||
* Subscribe to the appropriate PWM output topic based on whether we are the
|
||||
* primary PWM output or not.
|
||||
@@ -1027,11 +1025,6 @@ PX4IO::task_main()
|
||||
/* run at 5Hz */
|
||||
orb_check_last = now;
|
||||
|
||||
/* try to claim the MAVLink log FD */
|
||||
if (_mavlink_fd < 0) {
|
||||
_mavlink_fd = ::open(MAVLINK_LOG_DEVICE, 0);
|
||||
}
|
||||
|
||||
/* check updates on uORB topics and handle it */
|
||||
bool updated = false;
|
||||
|
||||
@@ -1087,7 +1080,7 @@ PX4IO::task_main()
|
||||
int pret = io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_VBATT_SCALE, &scaling, 1);
|
||||
|
||||
if (pret != OK) {
|
||||
mavlink_and_console_log_critical(_mavlink_fd, "IO vscale upload failed");
|
||||
mavlink_and_console_log_critical(&_mavlink_log_pub, "IO vscale upload failed");
|
||||
}
|
||||
|
||||
/* send RC throttle failsafe value to IO */
|
||||
@@ -1104,7 +1097,7 @@ PX4IO::task_main()
|
||||
pret = io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_RC_THR_FAILSAFE_US, &failsafe_thr, 1);
|
||||
|
||||
if (pret != OK) {
|
||||
mavlink_and_console_log_critical(_mavlink_fd, "failsafe upload failed, FS: %d us", (int)failsafe_thr);
|
||||
mavlink_and_console_log_critical(&_mavlink_log_pub, "failsafe upload failed, FS: %d us", (int)failsafe_thr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1546,7 +1539,7 @@ PX4IO::io_set_rc_config()
|
||||
|
||||
/* check the IO initialisation flag */
|
||||
if (!(io_reg_get(PX4IO_PAGE_STATUS, PX4IO_P_STATUS_FLAGS) & PX4IO_P_STATUS_FLAGS_INIT_OK)) {
|
||||
mavlink_and_console_log_critical(_mavlink_fd, "config for RC%d rejected by IO", i + 1);
|
||||
mavlink_and_console_log_critical(&_mavlink_log_pub, "config for RC%d rejected by IO", i + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1619,16 +1612,16 @@ void
|
||||
PX4IO::dsm_bind_ioctl(int dsmMode)
|
||||
{
|
||||
if (!(_status & PX4IO_P_STATUS_FLAGS_SAFETY_OFF)) {
|
||||
mavlink_log_info(_mavlink_fd, "[IO] binding DSM%s RX", (dsmMode == 0) ? "2" : ((dsmMode == 1) ? "-X" : "-X8"));
|
||||
mavlink_log_info(&_mavlink_log_pub, "[IO] binding DSM%s RX", (dsmMode == 0) ? "2" : ((dsmMode == 1) ? "-X" : "-X8"));
|
||||
int ret = ioctl(nullptr, DSM_BIND_START,
|
||||
(dsmMode == 0) ? DSM2_BIND_PULSES : ((dsmMode == 1) ? DSMX_BIND_PULSES : DSMX8_BIND_PULSES));
|
||||
|
||||
if (ret) {
|
||||
mavlink_log_critical(_mavlink_fd, "binding failed.");
|
||||
mavlink_log_critical(&_mavlink_log_pub, "binding failed.");
|
||||
}
|
||||
|
||||
} else {
|
||||
mavlink_log_info(_mavlink_fd, "[IO] system armed, bind request rejected");
|
||||
mavlink_log_info(&_mavlink_log_pub, "[IO] system armed, bind request rejected");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2148,7 +2141,7 @@ PX4IO::mixer_send(const char *buf, unsigned buflen, unsigned retries)
|
||||
} while (retries > 0);
|
||||
|
||||
if (retries == 0) {
|
||||
mavlink_and_console_log_info(_mavlink_fd, "[IO] mixer upload fail");
|
||||
mavlink_and_console_log_info(&_mavlink_log_pub, "[IO] mixer upload fail");
|
||||
/* load must have failed for some reason */
|
||||
return -EINVAL;
|
||||
|
||||
|
||||
@@ -50,8 +50,8 @@
|
||||
#include <termios.h>
|
||||
|
||||
#include <systemlib/err.h>
|
||||
#include <systemlib/mavlink_log.h>
|
||||
#include <arch/board/board.h>
|
||||
#include <mavlink/mavlink_log.h>
|
||||
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/topics/actuator_controls_0.h>
|
||||
|
||||
Reference in New Issue
Block a user