Commit Graph

39 Commits

Author SHA1 Message Date
Xiang Xiao
a5ef6d57c1 system/cu: Remove the dependence on stdio FILE * function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-09-06 14:29:34 +02:00
Xiang Xiao
5f9d9bb1c2 system/cu: Support the custom escape char
note: -f could be achieved with -E '' like https://linux.die.net/man/1/cu

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-09-06 14:29:34 +02:00
Xiang Xiao
b60cdf4927 system/cu: Skip the terminal related stuff if dev isn't a tty
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-09-06 14:29:34 +02:00
Xiang Xiao
3ff51d108b system/cu: Merge infd and outfd into devfd
to avoid opening the same device twice since
some special device can't work in this case

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-09-06 14:29:34 +02:00
renzhiyuan1
fece67ee4b Fix wrong parameter size
Type int expects 4 bytes for function write(). Type char expects 1 byte which matches the real usage of function write().

Signed-off-by: renzhiyuan1 <renzhiyuan1@xiaomi.com>
2023-08-30 19:42:57 +03:00
chao an
65ee6bea44 system/cu: disable error print if SYSTEM_CUTERM_DISABLE_ERROR_PRINT enabled
Test on sim/nsh (CONFIG_SYSTEM_CUTERM_DISABLE_ERROR_PRINT=y):

   text	   data	    bss	    dec	    hex	filename
 397049	  26704	   4128	 427881	  68769	nuttx      /* before */
 396481	  26704	   4128	 427313	  68531	nuttx      /* after */
   -568

Signed-off-by: chao an <anchao@xiaomi.com>
2023-06-10 02:29:47 +08:00
Xiang Xiao
fd9c92e2e9 system/cu: Move fd_std_tty, g_tio_std and g_tio_dev to cu_globals_s
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-29 14:50:11 +03:00
Xiang Xiao
35edbf02f5 system/cu: Remove the duplicated SIGINT definition
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-26 09:12:45 -06:00
Huang Qi
4079f6d613 system/cu: Let remote machine handle special character except Ctrl-C
Let remote machine handle special character except Ctrl-C, make cu's behavior more close to linux/bsd system.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-03-22 11:51:04 -03:00
Xiang Xiao
86080a110e apps: Remove the check of CONFIG_SERIAL_TERMIOS
If the code only change c_oflag, c_iflag and c_lflag, not c_cflag in termios.
Follow up the change from kernel: https://github.com/apache/nuttx/pull/8843

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-19 14:53:44 -06:00
Huang Qi
96cd66cf51 system/cu: Disable echo if it's enabled to avoid double input character
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-03-07 09:50:54 +01:00
ligd
79a137495a cu: fix cu hang when meet ctrl + C
We can't do sem_wait in sigaction

hang backtrace:
[<0x2c5a6958>] arm_switchcontext+0xc/0x10
[<0x2c579eba>] nxsem_wait+0x6e/0xa8
[<0x3c9a8cb5>] pb_field_iter_find+0xffde8cb/0xd3635c15
[<0x2c58d164>] uart_tcdrain.constprop.0+0x10/0xf8
[<0x2c58d5c6>] uart_close+0x10e/0x180
[<0x2c579f38>] nxsem_wait_uninterruptible+0x44/0xb8
[<0x2c95f87a>] file_close+0x12/0x44
[<0x2c95e5a8>] close+0x80/0xb4
[<0x2c5c6396>] sigint+0x1a/0x28
[<0x2c57b1b0>] nxsig_deliver+0x54/0xb8
[<0x2c5a549a>] arm_sigdeliver+0x1a/0x44
[<0x2c579eb6>] nxsem_wait+0x6a/0xa8
[<0x2c579eb6>] nxsem_wait+0x6a/0xa8
[<0x2c579eb6>] nxsem_wait+0x6a/0xa8
[<0x2c58aa1a>] pm_lock+0x1a/0x28
[<0x2c58a656>] pm_stay+0xa/0x60
[<0x2c58bb14>] rptun_notify+0x4c/0x58
[<0x2c97b8fc>] virtqueue_kick+0x54/0x7c
[<0x2c97ac82>] rpmsg_virtio_send_offchannel_nocopy+0x9a/0xcc
[<0x2c58df7c>] uart_rpmsg_dmasend+0x8c/0xe0
[<0x2c5771be>] leave_critical_section+0x2e/0x54
[<0x2c58d124>] uart_write+0x11c/0x14c
[<0x2c9620c6>] write+0x32/0x50
[<0x2c5c665e>] cu_main+0x2ba/0x484
[<0x2c5957be>] nxtask_startup+0x12/0x24
[<0x2c57b9d2>] nxtask_start+0x46/0x60

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-29 19:21:52 +03:00
Oleg
51c778bc5c system/cu: fix setting termios with parity
clear only the bits in c_cflag that will be set by cu
2021-07-19 03:06:57 -07:00
Alin Jerpelea
01532a45d6 system: fix relative path CI error
error: Path relative to repository other than nuttx must begin with the root directory
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-06-16 09:03:06 -05:00
ligd
d791afff4c system/cu/cu_main.c: ctrlC will send SIGINT/SIGSTP
N/A

Change-Id: I67f02977d206875cf1bd9cae4973c49af1db4c1d
Signed-off-by: ligd <liguiding1@xiaomi.com>
2020-10-27 10:16:55 -07:00
Juha Niskanen
2b88677895 system/cu: do not reset baud rate to zero when parity options are used
cfsetspeed() now stores baud rate to c_cflag member of
struct termios, so it must not be overridden later on.

Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-10-20 01:08:22 +08:00
Juha Niskanen
a20cf0980d system/cu: do not exit directly from getopt loop, bad in flat builds
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-10-20 01:08:22 +08:00
Oleg Evseev
fcd3937d7c system/cu: refactor, add option -c to disable \n -> \r\n conversion
option -c will disable \n -> \r\n conversion both for serial device and console if it is a tty

refactor: use only one function to set termios parameters, use termious related code and options only if CONFIG_SERIAL_TERMIOS is defined
2020-08-14 00:58:55 +01:00
Xiang Xiao
e4b101d2ef system/cu: Echo NULL char too
since zero is also a valid character

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-16 20:50:40 +09:00
Ouss4
7694f21292 system/cu/cu_main.c: Fix nxstyle complaints. 2020-03-13 16:36:03 -06:00
Oleg Evseev
df5d4cd033 system/cu/cu_main.c: Add option -f to loop forever. 2020-03-13 16:36:03 -06:00
Oleg Evseev
f221d33525 system/cu/cu_main.c: Fix wrongly swapped parity options. 2020-03-13 16:36:03 -06:00
David Alessio
91276ba94e apps/system/cu/cu_main.c: (1) Fix early exit. getc(stdin) can return 0 the first time around. (2) Set optind to zero. getopt() was being left in a bad state, causing parsing errors on second use. (3) Fix priority of cu_listen(). (4) Add suppor for -h. 2019-11-05 07:07:02 -06:00
Xiang Xiao
e806097c70 Application.mk and main.c files: Change builtin's entry point from main to xxx_main by macro expansion. This change make the entry point fully compliant with POSIX/ANSI standard. 2019-10-06 06:14:56 -06:00
anchao
b5cfd93444 apps/: Modification to build system: Unified application compilation rules 2018-09-03 09:29:56 -06:00
Gregory Nutt
b33eaf881d apps/system/cu: Fix undefined SIGKILL if CONFIG_SIG_DEFUALT is not defined. 2018-08-29 05:39:01 -06:00
Gregory Nutt
a1b9fc8bd8 apps/system/cu: SIGKILL is more appropriate that SIGINT in this circustance. 2018-08-28 12:09:25 -06:00
Gregory Nutt
bb4c5c49ef Replace usage of SIGKILL with SIGINIT 2018-08-28 12:02:26 -06:00
anchao
220653f21c Squashed commit of the following:
Author: anchao <anchao@pinecone.net>

     apps/, most main() function: Correct CONFIG_BUILD_LOADABLE usage
     Loadable apps/: Correct loadable symbol table generate
     apps/system/ubloxmodem:  Fix build break
     apps/examples/ostest: start restart/waitpid/user test from main loop
     apps/nshlib:  Expand reboot and poweroff commands to include a second, optional mode argument

    Author: Gregory Nutt <gnutt@nuttx.org>

     An attempt to fix build issues.  Does not work.
     apps/examples/ostest:  Fix some inappropriate renaming of static functions introduced with recent patches.
     apps/builtin/exec_builtin.c:  Fix a error introduced by recent comments.  Found in build testing.

    Author: anchao <anchao@pinecone.net>

     apps/builtin/exec_builtin.c:  Try posix_spawn if builtin apps do not have have an entry point.
     apps/Application.mk: introduce MODULE config to simplify tristate(m)
     apps/nsh:  Change the nuttx shell module type to tristate
     apps:  Add loadable application support
     script/mksymtab:  Generate symbol table name by default
     apps/builtin:  Allow loadable applications can register with apps/builtin.
2018-08-23 11:06:15 -06:00
ligd
feb1229dc3 apps/system/cu/cu_main.c: (1) Protect from possible re-definition of signal values, (2) Fix CU ctrl-C hand when remote core hang. 2018-08-23 07:05:09 -06:00
Gregory Nutt
2f982e9c77 Revert "Squashed commit of the following:"
This reverts commit 25b92edd9f.
2018-08-22 12:06:32 -06:00
anchao
25b92edd9f Squashed commit of the following:
apps/builtin/exec_builtin.c:  Try posix_spawn if builtin apps do not have have an entry point.
    apps/Application.mk: introduce MODULE config to simplify tristate(m)
    apps/nsh:  Change the nuttx shell module type to tristate
    apps:  Add loadable application support
    script/mksymtab:  Generate symbol table name by default
    apps/builtin:  Allow loadable applications can register with apps/builtin.
2018-08-22 09:30:38 -06:00
Juha Niskanen
0bcd50d7a1 apps/: Make more globals static to avoid name clashes 2017-05-19 07:13:12 -06:00
Sebastien Lorquet
2cbad44f1d This is the Pokemon patch to change all includes fronm <apps/bla/bla.h> to "bla/bla.h" 2016-07-11 10:11:18 -06:00
Gregory Nutt
cd741c82cf apps/include: Move all header files associated with modules in apps/system to apps/include/system 2016-07-01 06:48:22 -06:00
Gregory Nutt
aacfce081e Fix several cosmetic, C coding style issues 2015-10-03 11:03:42 -06:00
Gregory Nutt
ad1f59f497 apps/system/cu: Add a some configurable defaults (only to reduce my keystrokes in repetitive testing) 2014-12-13 13:11:06 -06:00
Gregory Nutt
dabe412e70 Add a minimalist implemention of the 'cu' terminal program (part of Taylor UUCP for ages). Using it, you can simply open a serial port and interact with it. Using '~.' you can leave the terminal program and drop back to nsh.
This might  come in handy for other people that have e.g. GSM modems, GPS receivers or other devices with text based serial communications attached to their Nuttx systems.
2014-12-13 10:36:37 -06:00
Gregory Nutt
bffa1da92a . 2014-12-13 10:34:11 -06:00