mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-29 11:40:28 +08:00
feat(mavlink): add a raw UART mode flag
The -a flag configures the port as a raw 8-bit local line without touching the baud rate, instead of the serial port setup PX4 applies to real UARTs. Virtual ttys such as the i.MX95 RPMsg proxy port to Linux need this. Co-authored-by: Hamish Willee <hamishwillee@gmail.com> Co-authored-by: Andre Heinemans <andre.heinemans@nxp.com>
This commit is contained in:
1 parent
f28b9453ae
commit
6f536efad6
2 files changed
+16
-1
No files matched your search
@@ -790,6 +790,15 @@ Mavlink::mavlink_open_uart(const int baud, const char *uart_name, const FLOW_CON
|
||||
cfmakeraw(&uart_config);
|
||||
#endif
|
||||
|
||||
if (_raw_mode) {
|
||||
/* no input/output processing, 8N1, no modem control; keep the baud rate */
|
||||
memset(&uart_config, 0, sizeof(uart_config));
|
||||
uart_config.c_cflag = CS8 | CREAD | CLOCAL;
|
||||
uart_config.c_cc[VMIN] = 1;
|
||||
cfsetispeed(&uart_config, speed);
|
||||
cfsetospeed(&uart_config, speed);
|
||||
}
|
||||
|
||||
if ((termios_state = tcsetattr(_uart_fd, TCSANOW, &uart_config)) < 0) {
|
||||
PX4_WARN("ERR SET CONF %s\n", uart_name);
|
||||
::close(_uart_fd);
|
||||
@@ -2409,7 +2418,7 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
int temp_int_arg;
|
||||
#endif
|
||||
|
||||
while ((ch = px4_getopt(argc, argv, "b:r:d:n:u:o:m:t:c:F:fswxzZp", &myoptind, &myoptarg)) != EOF) {
|
||||
while ((ch = px4_getopt(argc, argv, "b:r:d:n:u:o:m:t:c:F:fswxzZpa", &myoptind, &myoptarg)) != EOF) {
|
||||
switch (ch) {
|
||||
case 'b':
|
||||
if (px4_get_parameter_value(myoptarg, _baudrate) != 0) {
|
||||
@@ -2653,6 +2662,10 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
_flow_control = FLOW_CONTROL_OFF;
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
_raw_mode = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
err_flag = true;
|
||||
break;
|
||||
@@ -4028,6 +4041,7 @@ $ mavlink stream -u 14556 -s HIGHRES_IMU -r 50
|
||||
PRINT_MODULE_USAGE_PARAM_FLAG('x', "Enable FTP", true);
|
||||
PRINT_MODULE_USAGE_PARAM_FLAG('z', "Force hardware flow control always on", true);
|
||||
PRINT_MODULE_USAGE_PARAM_FLAG('Z', "Force hardware flow control always off", true);
|
||||
PRINT_MODULE_USAGE_PARAM_FLAG('a', "Configure serial port in raw mode (8N1, no termios processing), e.g. for NuttX RPMsg ttys", true);
|
||||
|
||||
PRINT_MODULE_USAGE_COMMAND_DESCR("stop-all", "Stop all instances");
|
||||
|
||||
|
||||
@@ -696,6 +696,7 @@ private:
|
||||
bool _udp_initialised{false};
|
||||
|
||||
FLOW_CONTROL_MODE _flow_control_mode{Mavlink::FLOW_CONTROL_OFF};
|
||||
bool _raw_mode{false};
|
||||
|
||||
uint64_t _last_write_success_time{0};
|
||||
uint64_t _last_write_try_time{0};
|
||||
|
||||
Reference in new issue
Block a user