mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
Lunchtime HOTFIX: Bring back USB console to operational, allow single-USB connection operation via QGC
This commit is contained in:
@@ -34,9 +34,10 @@ fi
|
|||||||
# ALWAYS start this task before the
|
# ALWAYS start this task before the
|
||||||
# preflight_check.
|
# preflight_check.
|
||||||
#
|
#
|
||||||
sensors start
|
if sensors start
|
||||||
|
then
|
||||||
#
|
#
|
||||||
# Check sensors - run AFTER 'sensors start'
|
# Check sensors - run AFTER 'sensors start'
|
||||||
#
|
#
|
||||||
preflight_check
|
preflight_check
|
||||||
|
fi
|
||||||
@@ -5,8 +5,33 @@
|
|||||||
|
|
||||||
echo "Starting MAVLink on this USB console"
|
echo "Starting MAVLink on this USB console"
|
||||||
|
|
||||||
|
# Stop tone alarm
|
||||||
|
tone_alarm stop
|
||||||
|
|
||||||
# Tell MAVLink that this link is "fast"
|
# Tell MAVLink that this link is "fast"
|
||||||
mavlink start -b 230400 -d /dev/console
|
if mavlink stop
|
||||||
|
then
|
||||||
|
echo "stopped other MAVLink instance"
|
||||||
|
fi
|
||||||
|
mavlink start -b 230400 -d /dev/ttyACM0
|
||||||
|
|
||||||
|
# Start the commander
|
||||||
|
commander start
|
||||||
|
|
||||||
|
# Start sensors
|
||||||
|
sh /etc/init.d/rc.sensors
|
||||||
|
|
||||||
|
# Start one of the estimators
|
||||||
|
if attitude_estimator_ekf start
|
||||||
|
then
|
||||||
|
echo "estimating attitude"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start GPS
|
||||||
|
if gps start
|
||||||
|
then
|
||||||
|
echo "GPS started"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "MAVLink started, exiting shell.."
|
echo "MAVLink started, exiting shell.."
|
||||||
|
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ __EXPORT int nsh_archinitialize(void)
|
|||||||
/* initial LED state */
|
/* initial LED state */
|
||||||
drv_led_start();
|
drv_led_start();
|
||||||
led_off(LED_AMBER);
|
led_off(LED_AMBER);
|
||||||
led_on(LED_BLUE);
|
led_off(LED_BLUE);
|
||||||
|
|
||||||
|
|
||||||
/* Configure SPI-based devices */
|
/* Configure SPI-based devices */
|
||||||
|
|||||||
@@ -1221,7 +1221,8 @@ start()
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if (g_dev != nullptr)
|
if (g_dev != nullptr)
|
||||||
errx(1, "already started");
|
/* if already started, the still command succeeded */
|
||||||
|
errx(0, "already started");
|
||||||
|
|
||||||
/* create the driver, attempt expansion bus first */
|
/* create the driver, attempt expansion bus first */
|
||||||
g_dev = new HMC5883(PX4_I2C_BUS_EXPANSION);
|
g_dev = new HMC5883(PX4_I2C_BUS_EXPANSION);
|
||||||
|
|||||||
@@ -1063,7 +1063,8 @@ start()
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if (g_dev != nullptr)
|
if (g_dev != nullptr)
|
||||||
errx(1, "already started");
|
/* if already started, the still command succeeded */
|
||||||
|
errx(0, "already started");
|
||||||
|
|
||||||
/* create the driver */
|
/* create the driver */
|
||||||
g_dev = new MPU6000(1 /* XXX magic number */, (spi_dev_e)PX4_SPIDEV_MPU);
|
g_dev = new MPU6000(1 /* XXX magic number */, (spi_dev_e)PX4_SPIDEV_MPU);
|
||||||
|
|||||||
@@ -969,7 +969,8 @@ start()
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if (g_dev != nullptr)
|
if (g_dev != nullptr)
|
||||||
errx(1, "already started");
|
/* if already started, the still command succeeded */
|
||||||
|
errx(0, "already started");
|
||||||
|
|
||||||
/* create the driver */
|
/* create the driver */
|
||||||
g_dev = new MS5611(MS5611_BUS);
|
g_dev = new MS5611(MS5611_BUS);
|
||||||
|
|||||||
@@ -420,12 +420,12 @@ int mavlink_open_uart(int baud, const char *uart_name, struct termios *uart_conf
|
|||||||
case 921600: speed = B921600; break;
|
case 921600: speed = B921600; break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "[mavlink] ERROR: Unsupported baudrate: %d\n\tsupported examples:\n\n\t9600\n19200\n38400\n57600\n115200\n230400\n460800\n921600\n\n", baud);
|
warnx("ERROR: Unsupported baudrate: %d\n\tsupported examples:\n\n\t9600\n19200\n38400\n57600\n115200\n230400\n460800\n921600\n\n", baud);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* open uart */
|
/* open uart */
|
||||||
printf("[mavlink] UART is %s, baudrate is %d\n", uart_name, baud);
|
warnx("UART is %s, baudrate is %d\n", uart_name, baud);
|
||||||
uart = open(uart_name, O_RDWR | O_NOCTTY);
|
uart = open(uart_name, O_RDWR | O_NOCTTY);
|
||||||
|
|
||||||
/* Try to set baud rate */
|
/* Try to set baud rate */
|
||||||
@@ -433,11 +433,9 @@ int mavlink_open_uart(int baud, const char *uart_name, struct termios *uart_conf
|
|||||||
int termios_state;
|
int termios_state;
|
||||||
*is_usb = false;
|
*is_usb = false;
|
||||||
|
|
||||||
/* make some wild guesses including that USB serial is indicated by either /dev/ttyACM0 or /dev/console */
|
|
||||||
if (strcmp(uart_name, "/dev/ttyACM0") != OK && strcmp(uart_name, "/dev/console") != OK) {
|
|
||||||
/* Back up the original uart configuration to restore it after exit */
|
/* Back up the original uart configuration to restore it after exit */
|
||||||
if ((termios_state = tcgetattr(uart, uart_config_original)) < 0) {
|
if ((termios_state = tcgetattr(uart, uart_config_original)) < 0) {
|
||||||
fprintf(stderr, "[mavlink] ERROR getting baudrate / termios config for %s: %d\n", uart_name, termios_state);
|
warnx("ERROR get termios config %s: %d\n", uart_name, termios_state);
|
||||||
close(uart);
|
close(uart);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -448,24 +446,24 @@ int mavlink_open_uart(int baud, const char *uart_name, struct termios *uart_conf
|
|||||||
/* Clear ONLCR flag (which appends a CR for every LF) */
|
/* Clear ONLCR flag (which appends a CR for every LF) */
|
||||||
uart_config.c_oflag &= ~ONLCR;
|
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) {
|
||||||
|
|
||||||
/* Set baud rate */
|
/* Set baud rate */
|
||||||
if (cfsetispeed(&uart_config, speed) < 0 || cfsetospeed(&uart_config, speed) < 0) {
|
if (cfsetispeed(&uart_config, speed) < 0 || cfsetospeed(&uart_config, speed) < 0) {
|
||||||
fprintf(stderr, "[mavlink] ERROR setting baudrate / termios config for %s: %d (cfsetispeed, cfsetospeed)\n", uart_name, termios_state);
|
warnx("ERROR setting baudrate / termios config for %s: %d (cfsetispeed, cfsetospeed)\n", uart_name, termios_state);
|
||||||
close(uart);
|
close(uart);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if ((termios_state = tcsetattr(uart, TCSANOW, &uart_config)) < 0) {
|
if ((termios_state = tcsetattr(uart, TCSANOW, &uart_config)) < 0) {
|
||||||
fprintf(stderr, "[mavlink] ERROR setting baudrate / termios config for %s (tcsetattr)\n", uart_name);
|
warnx("ERROR setting baudrate / termios config for %s (tcsetattr)\n", uart_name);
|
||||||
close(uart);
|
close(uart);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
*is_usb = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return uart;
|
return uart;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -751,7 +749,6 @@ int mavlink_thread_main(int argc, char *argv[])
|
|||||||
pthread_join(uorb_receive_thread, NULL);
|
pthread_join(uorb_receive_thread, NULL);
|
||||||
|
|
||||||
/* Reset the UART flags to original state */
|
/* Reset the UART flags to original state */
|
||||||
if (!usb_uart)
|
|
||||||
tcsetattr(uart, TCSANOW, &uart_config_original);
|
tcsetattr(uart, TCSANOW, &uart_config_original);
|
||||||
|
|
||||||
thread_running = false;
|
thread_running = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user