forked from Archive/PX4-Autopilot
Mavlink startup script per board
-moved rc.mavlink to the boards optional rc additions (now it's called rc.board_mavlink) to handle board specific mavlink needs (mavlink over usb, ethernet, additional streams, etc.) -mavlink module will be responsible to usb defaults, therefore less args are needed to be passed to mavlink module if one wants to use mavlink over usb. -the way to check if connection is usb is by it's designated variable and not by config mode.
This commit is contained in:
parent
fdefaf1ad3
commit
bbb96cbd0c
|
@ -143,6 +143,7 @@ list(APPEND OPTIONAL_BOARD_RC
|
|||
rc.board_defaults
|
||||
rc.board_sensors
|
||||
rc.board_extras
|
||||
rc.board_mavlink
|
||||
)
|
||||
|
||||
foreach(board_rc_file ${OPTIONAL_BOARD_RC})
|
||||
|
|
|
@ -39,7 +39,6 @@ px4_add_romfs_files(
|
|||
rc.interface
|
||||
rc.io
|
||||
rc.logging
|
||||
rc.mavlink
|
||||
rc.mc_apps
|
||||
rc.mc_defaults
|
||||
rcS
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# MAVLink startup script.
|
||||
#
|
||||
# NOTE: Script variables are declared/initialized/unset in the rcS script.
|
||||
#
|
||||
|
||||
if ! ver hwcmp INTEL_AEROFC_V1
|
||||
then
|
||||
# Start MAVLink on the USB port
|
||||
mavlink start -r 800000 -d /dev/ttyACM0 -m config -x
|
||||
fi
|
||||
|
|
@ -396,9 +396,15 @@ else
|
|||
fi
|
||||
|
||||
#
|
||||
# Start mavlink streams that are not configurable (e.g. on USB).
|
||||
# Optional board mavlink streams: rc.board_mavlink
|
||||
#
|
||||
sh /etc/init.d/rc.mavlink
|
||||
set BOARD_RC_MAVLINK /etc/init.d/rc.board_mavlink
|
||||
if [ -f $BOARD_RC_MAVLINK ]
|
||||
then
|
||||
echo "Board extras: ${BOARD_RC_MAVLINK}"
|
||||
sh $BOARD_RC_MAVLINK
|
||||
fi
|
||||
unset BOARD_RC_MAVLINK
|
||||
|
||||
#
|
||||
# Start UART/Serial device drivers.
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Airmind Mindpx-v2 specific board MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Start MAVLink on the USB port
|
||||
mavlink start -d /dev/ttyACM0
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# AUAV/mRO x21 specific board MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Start MAVLink on the USB port
|
||||
mavlink start -d /dev/ttyACM0
|
|
@ -1,8 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# av_x1-v1 specific board init
|
||||
#
|
||||
#
|
||||
# av_x1-v1 specific board MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# AV-X: start MAVLink to companion (connected to TX2)
|
||||
mavlink start -d /dev/ttyS5 -b 500000 -m osd
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Bitcraze Crazyflie specific board MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Start MAVLink on the USB port
|
||||
mavlink start -d /dev/ttyACM0
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# KakuteF7 specific specific board MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Start MAVLink on the USB port
|
||||
mavlink start -d /dev/ttyACM0
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# mRo Control Zero specific board MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Start MAVLink on the USB port
|
||||
mavlink start -d /dev/ttyACM0
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# NXP fmuk66-v3 specific board MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Start MAVLink on the USB port
|
||||
mavlink start -d /dev/ttyACM0
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# OmnibusF4SD specific board MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Start MAVLink on the USB port
|
||||
mavlink start -d /dev/ttyACM0
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PX4 FMUv2 specific board MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Start MAVLink on the USB port
|
||||
mavlink start -d /dev/ttyACM0
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PX4 FMUv3 specific board MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Start MAVLink on the USB port
|
||||
mavlink start -d /dev/ttyACM0
|
|
@ -3,13 +3,6 @@
|
|||
# PX4 FMUv4 specific board extras init
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# Pixracer: start MAVLink on Wifi (ESP8266 port). Except for the TealOne airframe.
|
||||
if ! param compare SYS_AUTOSTART 4250
|
||||
then
|
||||
mavlink start -r 20000 -b 921600 -d /dev/ttyS0
|
||||
fi
|
||||
|
||||
# Run FrSky Telemetry on Pixracer on the FrSky port if not enabled already
|
||||
if param compare TEL_FRSKY_CONFIG 0
|
||||
then
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PX4 FMUv4 specific board MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Start MAVLink on the USB port
|
||||
mavlink start -d /dev/ttyACM0
|
||||
|
||||
# Pixracer: start MAVLink on Wifi (ESP8266 port). Except for the TealOne airframe.
|
||||
if ! param compare SYS_AUTOSTART 4250
|
||||
then
|
||||
mavlink start -r 20000 -b 921600 -d /dev/ttyS0
|
||||
fi
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PX4 FMUv4pro specific board MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Start MAVLink on the USB port
|
||||
mavlink start -d /dev/ttyACM0
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PX4 FMUv5 specific board MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Start MAVLink on the USB port
|
||||
mavlink start -d /dev/ttyACM0
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PX4 FMUv5X specific board MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Start MAVLink on the USB port
|
||||
mavlink start -d /dev/ttyACM0
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# UVify UVF4 specific board MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Start MAVLink on the USB port
|
||||
mavlink start -d /dev/ttyACM0
|
|
@ -586,7 +586,7 @@ Mavlink::mavlink_open_uart(const int baud, const char *uart_name, const bool for
|
|||
}
|
||||
|
||||
/* back off 1800 ms to avoid running into the USB setup timing */
|
||||
while (_mode == MAVLINK_MODE_CONFIG &&
|
||||
while (_is_usb_uart &&
|
||||
hrt_absolute_time() < 1800U * 1000U) {
|
||||
px4_usleep(50000);
|
||||
}
|
||||
|
@ -595,7 +595,7 @@ Mavlink::mavlink_open_uart(const int baud, const char *uart_name, const bool for
|
|||
_uart_fd = ::open(uart_name, O_RDWR | O_NOCTTY);
|
||||
|
||||
/* if this is a config link, stay here and wait for it to open */
|
||||
if (_uart_fd < 0 && _mode == MAVLINK_MODE_CONFIG) {
|
||||
if (_uart_fd < 0 && _is_usb_uart) {
|
||||
|
||||
uORB::SubscriptionData<actuator_armed_s> armed_sub{ORB_ID(actuator_armed)};
|
||||
|
||||
|
@ -628,7 +628,6 @@ Mavlink::mavlink_open_uart(const int baud, const char *uart_name, const bool for
|
|||
/* Try to set baud rate */
|
||||
struct termios uart_config;
|
||||
int termios_state;
|
||||
_is_usb_uart = false;
|
||||
|
||||
/* Initialize the uart config */
|
||||
if ((termios_state = tcgetattr(_uart_fd, &uart_config)) < 0) {
|
||||
|
@ -640,8 +639,7 @@ Mavlink::mavlink_open_uart(const int baud, const char *uart_name, const bool for
|
|||
/* Clear ONLCR flag (which appends a CR for every LF) */
|
||||
uart_config.c_oflag &= ~ONLCR;
|
||||
|
||||
/* USB serial is indicated by /dev/ttyACM0*/
|
||||
if (strcmp(uart_name, "/dev/ttyACM0") != OK && strcmp(uart_name, "/dev/ttyACM1") != OK) {
|
||||
if (!_is_usb_uart) {
|
||||
|
||||
/* Set baud rate */
|
||||
if (cfsetispeed(&uart_config, speed) < 0 || cfsetospeed(&uart_config, speed) < 0) {
|
||||
|
@ -651,7 +649,6 @@ Mavlink::mavlink_open_uart(const int baud, const char *uart_name, const bool for
|
|||
}
|
||||
|
||||
} else {
|
||||
_is_usb_uart = true;
|
||||
|
||||
/* USB has no baudrate, but use a magic number for 'fast' */
|
||||
_baudrate = 2000000;
|
||||
|
@ -1835,7 +1832,7 @@ Mavlink::task_main(int argc, char *argv[])
|
|||
int ch;
|
||||
_baudrate = 57600;
|
||||
_datarate = 0;
|
||||
_mode = MAVLINK_MODE_NORMAL;
|
||||
_mode = MAVLINK_MODE_COUNT;
|
||||
bool _force_flow_control = false;
|
||||
|
||||
_interface_name = nullptr;
|
||||
|
@ -2059,6 +2056,24 @@ Mavlink::task_main(int argc, char *argv[])
|
|||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
/* USB serial is indicated by /dev/ttyACM0*/
|
||||
if (strcmp(_device_name, "/dev/ttyACM0") == OK || strcmp(_device_name, "/dev/ttyACM1") == OK) {
|
||||
if (_datarate == 0) {
|
||||
_datarate = 800000;
|
||||
}
|
||||
|
||||
if (_mode == MAVLINK_MODE_COUNT) {
|
||||
_mode = MAVLINK_MODE_CONFIG;
|
||||
}
|
||||
|
||||
_ftp_on = true;
|
||||
_is_usb_uart = true;
|
||||
}
|
||||
|
||||
if (_mode == MAVLINK_MODE_COUNT) {
|
||||
_mode = MAVLINK_MODE_NORMAL;
|
||||
}
|
||||
|
||||
if (_datarate == 0) {
|
||||
/* convert bits to bytes and use 1/2 of bandwidth by default */
|
||||
_datarate = _baudrate / 20;
|
||||
|
@ -2083,11 +2098,11 @@ Mavlink::task_main(int argc, char *argv[])
|
|||
/* default values for arguments */
|
||||
_uart_fd = mavlink_open_uart(_baudrate, _device_name, _force_flow_control);
|
||||
|
||||
if (_uart_fd < 0 && _mode != MAVLINK_MODE_CONFIG) {
|
||||
if (_uart_fd < 0 && !_is_usb_uart) {
|
||||
PX4_ERR("could not open %s", _device_name);
|
||||
return PX4_ERROR;
|
||||
|
||||
} else if (_uart_fd < 0 && _mode == MAVLINK_MODE_CONFIG) {
|
||||
} else if (_uart_fd < 0 && _is_usb_uart) {
|
||||
/* the config link is optional */
|
||||
return OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue