1# Copyright (c) 2025, Nordic Semiconductor ASA
2# SPDX-License-Identifier: Apache-2.0
3
4config UART_NATIVE_PTY
5	bool "PTY based UART driver for native_sim"
6	default y
7	depends on DT_HAS_ZEPHYR_NATIVE_PTY_UART_ENABLED
8	select SERIAL_HAS_DRIVER
9	select SERIAL_SUPPORT_ASYNC
10	select SERIAL_SUPPORT_INTERRUPT
11	help
12	  This enables a PTY based UART driver for the POSIX ARCH with up to 2 UARTs.
13	  For the first UART port, the driver can be configured
14	  to either connect to the terminal from which the executable was run, or into
15	  one dedicated pseudoterminal for that UART.
16
17
18if UART_NATIVE_PTY
19
20choice UART_NATIVE_PTY_0
21	prompt "Native PTY Port 0 connection"
22	default UART_NATIVE_PTY_0_ON_OWN_PTY
23
24config UART_NATIVE_PTY_0_ON_OWN_PTY
25	bool "Connect the first PTY UART to its own pseudo terminal"
26	help
27	  Connect this UART to its own pseudoterminal. This is the preferred
28	  option for users who want to use Zephyr's shell.
29	  Moreover this option does not conflict with any other native
30	  backend which may use the invoking shell standard input/output.
31	  Note it can be overridden from command line
32
33config UART_NATIVE_PTY_0_ON_STDINOUT
34	bool "Connect the first PTY UART to the invoking shell stdin/stdout"
35	help
36	  Connect this UART to the stdin & stdout of the calling shell/terminal
37	  which invoked the native executable. This is good enough for
38	  automated testing, or when feeding from a file/pipe.
39	  Note that other, non UART messages, will also be printed to the
40	  terminal.
41	  It is strongly discouraged to try to use this option with the new
42	  shell interactively, as the default terminal configuration is NOT
43	  appropriate for interactive use.
44
45endchoice
46
47config UART_NATIVE_PTY_AUTOATTACH_DEFAULT_CMD
48	string "Default command to attach a PTY UART to a new terminal"
49	default "xterm -e screen %s &"
50	help
51	  If the native executable is called with the --attach_uart
52	  command line option, this will be the default command which will be
53	  run to attach a new terminal to the 1st UART.
54	  Note that this command must have one, and only one, '%s' as
55	  placeholder for the pseudoterminal device name (e.g. /dev/pts/35)
56	  This is only applicable if the UART_0 is configured to use its own
57	  PTY with UART_NATIVE_PTY_0_ON_OWN_PTY.
58	  The 2nd UART will not be affected by this option.
59	  If you are using GNOME, then you can use this command string
60	  'gnome-terminal -- screen %s'
61
62endif # UART_NATIVE_PTY
63