mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 09:21:35 +08:00
mavlink USB auto start/stop on boards with VBUS
- no longer start sercon or mavlink usb by default - on USB connection (VBUS) monitor serial USB at low rate and start Mavlink if there's a HEARTBEAT or nshterm on 3 consecutive carriage returns - the mavlink USB instance is automatically stopped and serdis executed if USB is disconnected - skipping Mavlink USB (and sercon) saves a considerable amount of memory on older boards
This commit is contained in:
@@ -125,6 +125,14 @@ public:
|
||||
*/
|
||||
static int start(int argc, char *argv[]);
|
||||
|
||||
bool running() const { return _task_running.load(); }
|
||||
bool should_exit() const { return _task_should_exit.load(); }
|
||||
void request_stop()
|
||||
{
|
||||
_task_should_exit.store(true);
|
||||
_receiver.request_stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the mavlink status.
|
||||
*/
|
||||
@@ -135,6 +143,7 @@ public:
|
||||
*/
|
||||
void display_status_streams();
|
||||
|
||||
static int stop_command(int argc, char *argv[]);
|
||||
static int stream_command(int argc, char *argv[]);
|
||||
|
||||
static int instance_count();
|
||||
@@ -166,6 +175,10 @@ public:
|
||||
|
||||
static void forward_message(const mavlink_message_t *msg, Mavlink *self);
|
||||
|
||||
bool check_events() const { return _should_check_events.load(); }
|
||||
void check_events_enable() { _should_check_events.store(true); }
|
||||
void check_events_disable() { _should_check_events.store(false); }
|
||||
|
||||
int get_uart_fd() const { return _uart_fd; }
|
||||
|
||||
/**
|
||||
@@ -455,8 +468,6 @@ public:
|
||||
|
||||
int get_socket_fd() { return _socket_fd; };
|
||||
|
||||
bool _task_should_exit{false}; /**< Mavlink task should exit iff true. */
|
||||
|
||||
#if defined(MAVLINK_UDP)
|
||||
unsigned short get_network_port() { return _network_port; }
|
||||
|
||||
@@ -529,7 +540,12 @@ public:
|
||||
|
||||
private:
|
||||
MavlinkReceiver _receiver;
|
||||
|
||||
int _instance_id{-1};
|
||||
int _task_id{-1};
|
||||
|
||||
px4::atomic_bool _task_should_exit{false};
|
||||
px4::atomic_bool _task_running{false};
|
||||
|
||||
bool _transmitting_enabled{true};
|
||||
bool _transmitting_enabled_commanded{false};
|
||||
@@ -540,12 +556,12 @@ private:
|
||||
uORB::Publication<vehicle_command_ack_s> _vehicle_command_ack_pub{ORB_ID(vehicle_command_ack)};
|
||||
uORB::PublicationMulti<telemetry_status_s> _telemetry_status_pub{ORB_ID(telemetry_status)};
|
||||
|
||||
uORB::Subscription _event_sub{ORB_ID(event)};
|
||||
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
|
||||
uORB::Subscription _vehicle_command_sub{ORB_ID(vehicle_command)};
|
||||
uORB::Subscription _vehicle_command_ack_sub{ORB_ID(vehicle_command_ack)};
|
||||
uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)};
|
||||
|
||||
bool _task_running{true};
|
||||
static bool _boot_complete;
|
||||
|
||||
static constexpr int MAVLINK_MIN_INTERVAL{1500};
|
||||
@@ -562,6 +578,8 @@ private:
|
||||
bool _wait_to_transmit{false}; /**< Wait to transmit until received messages. */
|
||||
bool _received_messages{false}; /**< Whether we've received valid mavlink messages. */
|
||||
|
||||
px4::atomic_bool _should_check_events{false}; /**< Events subscription: only one MAVLink instance should check */
|
||||
|
||||
unsigned _main_loop_delay{1000}; /**< mainloop delay, depends on data rate */
|
||||
|
||||
List<MavlinkStream *> _streams;
|
||||
|
||||
Reference in New Issue
Block a user