mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 19:32:36 +08:00
Merge pull request #2203 from NaterGator/mavlink_usbfix
Fix MAVLink USB UART detection
This commit is contained in:
@@ -577,7 +577,7 @@ int Mavlink::get_component_id()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __PX4_POSIX
|
#ifndef __PX4_POSIX
|
||||||
int Mavlink::mavlink_open_uart(int baud, const char *uart_name, struct termios *uart_config_original, bool *is_usb)
|
int Mavlink::mavlink_open_uart(int baud, const char *uart_name, struct termios *uart_config_original)
|
||||||
{
|
{
|
||||||
/* process baud rate */
|
/* process baud rate */
|
||||||
int speed;
|
int speed;
|
||||||
@@ -642,7 +642,7 @@ int Mavlink::mavlink_open_uart(int baud, const char *uart_name, struct termios *
|
|||||||
/* Try to set baud rate */
|
/* Try to set baud rate */
|
||||||
struct termios uart_config;
|
struct termios uart_config;
|
||||||
int termios_state;
|
int termios_state;
|
||||||
*is_usb = false;
|
_is_usb_uart = false;
|
||||||
|
|
||||||
/* 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_fd, uart_config_original)) < 0) {
|
if ((termios_state = tcgetattr(_uart_fd, uart_config_original)) < 0) {
|
||||||
@@ -667,6 +667,8 @@ int Mavlink::mavlink_open_uart(int baud, const char *uart_name, struct termios *
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_is_usb_uart = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((termios_state = tcsetattr(_uart_fd, TCSANOW, &uart_config)) < 0) {
|
if ((termios_state = tcsetattr(_uart_fd, TCSANOW, &uart_config)) < 0) {
|
||||||
@@ -1393,7 +1395,7 @@ Mavlink::task_main(int argc, char *argv[])
|
|||||||
struct termios uart_config_original;
|
struct termios uart_config_original;
|
||||||
|
|
||||||
/* default values for arguments */
|
/* default values for arguments */
|
||||||
_uart_fd = mavlink_open_uart(_baudrate, _device_name, &uart_config_original, &_is_usb_uart);
|
_uart_fd = mavlink_open_uart(_baudrate, _device_name, &uart_config_original);
|
||||||
|
|
||||||
if (_uart_fd < 0) {
|
if (_uart_fd < 0) {
|
||||||
warn("could not open %s", _device_name);
|
warn("could not open %s", _device_name);
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ private:
|
|||||||
void mavlink_update_system();
|
void mavlink_update_system();
|
||||||
|
|
||||||
#ifndef __PX4_QURT
|
#ifndef __PX4_QURT
|
||||||
int mavlink_open_uart(int baudrate, const char *uart_name, struct termios *uart_config_original, bool *is_usb);
|
int mavlink_open_uart(int baudrate, const char *uart_name, struct termios *uart_config_original);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static unsigned int interval_from_rate(float rate);
|
static unsigned int interval_from_rate(float rate);
|
||||||
|
|||||||
Reference in New Issue
Block a user