system/cu: Optimize I/O performance with batch read/write
Summary
Modify character-by-character read to block read of the entire buffer. Due to DMA-based transfers, the rx buffer can receive a large amount of data at once. The previous character-by-character processing approach was inefficient. This improves throughput and reduces CPU overhead, especially for high-speed serial communication or other DMA-based transfers.
Impact
No behavior changes: The user interface and command-line options remain unchanged, All escape sequences and commands work identically. No new configurations were added.
Testing
The change was tested on multiple platforms, including simulator, QEMU, and daily device test platforms. Verified stable operation, correct data forwarding, and no regressions compared to previous behavior. The following shows a self-test result obtained on sim, as well as logs captured from a device during regular operation.
sim:
$ ./rpproxy
$ ./rpserver
NuttShell (NSH) NuttX-12.11.0
server>
server> cu
NuttShell (NSH) NuttX-12.11.0
proxy>
proxy> aaaaaa~?bbbbbbb
nsh: aaaaaa~?bbbbbbb: command not found
proxy> aaaaaaa~.
nsh: aaaaaaa~.: command not found
proxy>
proxy> ~server> // ~. 退出
server> cu
proxy> hello
Hello, World!!
proxy> ls
/:
dev/
proc/
proxy> ~~~~~.
nsh: ~~~~.: command not found
proxy> ~~~~~~~~~.
nsh: ~~~~~~~~.: command not found
proxy> bbbbbbaaaa
nsh: bbbbbbaaaa: command not found
proxy> ~server>
server> cu -l /dev/ttyproxy
Hello, World!!
proxy> server> // ctrl + c
Device:
06:47:10.171 [Nuttx] ap>
06:47:10.208 Switching to core: cp
06:47:10.209 Attempting to switch to core: cp
06:47:10.290 [Nuttx] cu -l /dev/ttyCP
06:47:10.290 [Nuttx]
06:47:10.290 [Nuttx] cp>
06:47:10.309 Core switch to cp succeeded
06:47:10.392 [Nuttx]
06:47:10.800 [Nuttx] cp>
06:47:10.813 The current prompt is cp>
--------------------- live log call ---------------------------------
06:47:10.901 [Nuttx] cmocka -s cmocka_fs_test -t test_nuttx_fs_eventfd
06:47:11.002 [Nuttx] cp>
06:47:11.002 [Nuttx] cp>
06:47:11.103 [Nuttx] [12/15 12:42:35] [431] [cp] Cmocka Test Start.
06:47:11.103 [Nuttx] [12/15 12:42:35] [435] [cp] [==========] nuttx_fs_test_suites: Running 1 test(s).
06:47:11.103 [Nuttx] [12/15 12:42:35] [435] [cp] [ RUN ] test_nuttx_fs_eventfd
06:47:11.103 [Nuttx] [12/15 12:42:35] [435] [cp] [ OK ] test_nuttx_fs_eventfd
06:47:11.103 [Nuttx] [12/15 12:42:35] [435] [cp] [==========] nuttx_fs_test_suites: 1 test(s) run.
06:47:11.103 [Nuttx] [12/15 12:42:35] [435] [cp] [ PASSED ] 1 test(s).
06:47:11.103 [Nuttx] [12/15 12:42:35] [431] [cp] Cmocka Test Completed.
06:47:11 [ INFO] test_fs_integration[fs_eventfd_operations-cp] 118 PASS : Test Passed
------------------- live log teardown -------------------------------
06:47:11.115 Switching back to main core: ap
06:47:11.116 Sent Ctrl+c to the device process.
06:47:11.116 Successfully sent Ctrl+c
m/fs/fs/test_fs_integration.py::test_fs_integration[fs_eventfd_operations-audio]
--------------------- live log setup --------------------------------
06:47:11.118 login to device xxxxx
06:47:11.210 [Nuttx] ap>
06:47:11.210 [Nuttx] ap> uname -o
06:47:11.210 [Nuttx] NuttX
06:47:11.210 [Nuttx] ap>