ricardgb opened a new pull request, #22468:
URL: https://github.com/apache/nuttx/pull/22468

   ## Summary
   
   Fixes #22467.
   
   Three commits, in `arch/xtensa/src/esp32s3/esp32s3_usbserial.c` (and its 
Kconfig):
   
   1. **Style only.** The indentation of the `switch` of `esp32s3_ioctl()`. 
`checkpatch.sh`
      reports these errors on the file as it is on master, so the fixes alone 
would not pass.
   2. **Start of the transmission.** The driver sent only from the "IN empty" 
interrupt, raised
      when the host takes a packet, and `esp32s3_txint()` relied on the flag of 
an earlier packet
      still being pending. As far as I can tell from the code, when it was not, 
nothing was ever
   sent. Now `esp32s3_txint()` sends
      when the hardware buffer can take data, as other serial drivers do.
   3. **Transmit timeout.** New `CONFIG_ESP32S3_USBSERIAL_TXTIMEOUT` (ms, 
default 100). When the
      host takes no data for this time, the driver discards the data that wait 
in the transmit
      buffer, wakes the writers, and discards all the data written after that, 
until the hardware
      buffer is free again (the host reads). 0 keeps the old behaviour: a write 
waits for ever.
   
   **The third commit changes the default behaviour and I would like the 
opinion of the
   maintainers on it.** Today a write waits for the host without limit, so a 
board with the
   console on this port stops at its first messages when nobody reads the port. 
With the timeout
   the output of that time is lost instead. ESP-IDF does the same for this port 
(a timeout of the
   write, then the output is dropped until the host comes back). If you prefer 
the default 0, or
   the option on the board level, I will change it; the second commit does not 
depend on it.
   
   ## Impact
   
   ESP32-S3 with `CONFIG_ESP32S3_USBSERIAL`. With a host that reads the port 
nothing changes
   except that the output now starts in the case of the second commit. With no 
reader, a write
   returns after at most the timeout instead of never, and that output is lost. 
Size: one
   `struct wdog_s` and a flag in the driver state.
   
   ## Testing
   
   Host: Ubuntu, GCC 13 / xtensa-esp32s3-elf-gcc. Master `a63275cdce8`. 
ESP32-S3 (rev v0.2) on a
   Linux host, `/dev/ttyACM0`.
   
   **esp32s3-devkit:nsh** with the console on the USB-Serial/JTAG port and the 
reproducer of the
   issue as the init task (50 lines at start-up, then the time that they took):
   
   | | Port closed for 30 s, then opened without a reset | Reset with the port 
open (read for 7 s) |
   |---|---|---|
   | master | the 50 lines took 30190 ms | no output of the application, 6 of 6 
runs |
   | commit 2 only (`TXTIMEOUT=0`) | 30140 ms | all 50 lines, 4 of 4 runs |
   | this PR | 130 ms; the reports that follow arrive | all 50 lines, 4 of 4 
runs |
   
   **A board with WiFi and telnet**, console on this port, so that the port can 
be tested from a
   telnet session (`time "cat <file of 3652 bytes> > /dev/console"`):
   
   | | Port closed | Port open, a program reads it |
   |---|---|---|
   | master | does not return; returns when the port is opened | — |
   | this PR | 0.02 s (0.12 s the first time after the port was closed) | 0.15 
s, the host reads the data |
   
   The same board, system log and the output of the applications on the 
console, flashed and
   left with the port closed on the host:
   
   | | Result |
   |---|---|
   | master | does not join the network in 40 s, no HTTP |
   | this PR | on the network after 4 s, HTTP answers |
   
   With this PR nsh on the port still works (`uname -a`).
   
   `./tools/checkpatch.sh -g HEAD~3..HEAD`: all checks pass.
   
   *Disclosure: this change was prepared with the help of an AI agent (Claude 
Code, Anthropic); it
   was tested on real hardware and human-reviewed.*
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to