speccy88 opened a new pull request, #3632: URL: https://github.com/apache/nuttx-apps/pull/3632
## Summary Fix the Berry interactive console on raw NuttX terminals, including USB CDC ACM consoles that do not provide canonical input, CR-to-LF conversion, or driver echo. The pinned Berry default port uses `fgets()`. On a raw console, Enter commonly arrives as CR rather than LF, so the REPL and `input()` wait indefinitely. Routing Berry through the shared NuttX readline implementation also leaks NSH history and tab completion into the interpreter. This change: - adds an opt-in `USE_NUTTX_CONSOLE` reader to the pinned Berry source; - accepts CR, LF, and CRLF line endings; - handles a queued LF left by a CRLF command that launched Berry from NSH; - provides termios-aware local echo and BS/DEL editing without double echo; - treats ETX or an interrupted read as console termination so Ctrl-C returns to NSH; - keeps Berry input isolated from NSH readline history, completion, and prompt state; and - enables the reader in both Make and CMake builds. The normal Berry `fgets()` path remains unchanged when `USE_NUTTX_CONSOLE` is not defined. The equivalent source fix is also proposed upstream in [berry-lang/berry#539](https://github.com/berry-lang/berry/pull/539). This local patch is needed for the Berry commit currently pinned by NuttX Apps. ## Impact - User impact: Berry REPL and `input()` work on raw serial and USB CDC terminals. - Build impact: Berry alone receives one additional compile definition and pinned-source patch. - Other applications: unchanged; `system/readline` is not modified. - Compatibility: the existing stdio fallback is preserved. ## Verification Fruit Jam RP2350 hardware, minimal NuttX image over raw USB CDC ACM: - CR-only, LF-only, and CRLF input all complete. - A CRLF launch no longer leaves an empty line for the first `input()` call. - Piped `berry\r\n6*7\r\n` preserves the first expression byte and evaluates to `42`. - CRLF `10+5` evaluates to `15` with one following prompt. - A following CR-only `2+3` evaluates to `5`. - LF-only empty input remains valid. - Berry input is not recalled by NSH history, and Tab does not expose NSH completions. - Ctrl-C exits Berry and returns to the NSH prompt. Build and local checks: - Exact patched `default/be_port.c` blob: `7d52aebe055b098febec472f32690c1ef71780e3`. - Strict standalone Berry build with `-Wall -Wextra -std=c99 -pedantic-errors -DUSE_NUTTX_CONSOLE` passed. - `sim:berry` Make build passed; `berry -e "print(6*7)"` returned `42`. - CMake FetchContent applied both patches and compiled the final `be_port.c` successfully; the full `sim:berry` CMake/Ninja path passed before the final hardware-only handoff addition. - Pipe and raw-PTY tests covered CR, LF, delayed CRLF, non-LF after CR, empty LF input, BS, DEL, ETX, queued first input, echo, and `input()` prompt flushing. - `git diff --check` passed. - NuttX `checkpatch.sh` and `cmake-format` passed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
