Keep USB line coding diagnostic only. Fix cdc connect reconfiguring UART

1
This commit is contained in:
2026-08-31 03:40:55 +02:00
parent 6ad6c00d68
commit 2aafff25be
8 changed files with 16 additions and 153 deletions
+1 -1
View File
@@ -92,7 +92,7 @@ The broker currently enters nonblocking serial read/write APIs while holding its
`usb_cdc_transport` has a permanent transport task and TinyUSB callbacks. Attached plus host DTR asserted is treated as open. Opening starts the serial service if necessary, creates the `usb-cdc` broker client, and opportunistically requests writer ownership; otherwise USB observes.
TinyUSB callbacks enqueue/copy data and state; the transport task owns broker lifecycle and forwarding. The callback caches the latest supported host line coding regardless of current writer state; the task applies it only while USB is writer, the serial service is running, and TX is empty. The pending value is discarded when the CDC session closes and is not automatically persisted.
TinyUSB callbacks enqueue/copy data and state; the transport task owns broker lifecycle and forwarding. The line-coding callback records the latest host setting for diagnostics only. It never reconfigures UART1: physical framing and speed remain controlled by the explicit serial configuration, regardless of USB writer ownership.
### HTTPS, WebSocket, and web serial
+1 -1
View File
@@ -54,7 +54,7 @@ This is a semantic map, not a complete file inventory. Start here, then read the
- Dependencies: TinyUSB, broker, serial service
- Flow: `USB host <-> USB task <-> broker`
- Lifecycle: permanent owner task; broker client exists only while attached with host DTR asserted.
- Constraint: callbacks cache the latest host line coding; the task applies it only while USB is writer, UART is running, and TX is empty. It is RAM-only and is discarded when the CDC session closes.
- Constraint: callbacks retain the latest host line coding only for diagnostics; it never reconfigures UART1. UART1 framing and speed remain controlled by the serial configuration and its explicit persistence commands.
## Web and WebSocket serial
+7 -1
View File
@@ -46,7 +46,13 @@ These observations should be checked when touching the relevant area; they are n
## Active Task
No active task recorded.
- **Objective:** Prevent USB CDC host line coding from implicitly reconfiguring UART1 when USB becomes writer.
- **Relevant files:** `src/usb_cdc_transport.{c,h}`, `src/usb_console.c`, USB serial documentation.
- **Findings:** The transport converted cached CDC line coding into `serial_config_t` and called `serial_service_apply_config()` after writer acquisition. That deliberately stopped/restarted UART1 and changed its RAM configuration.
- **Decision:** Treat CDC line coding as diagnostic metadata only. UART1 configuration remains exclusively controlled by explicit `serial` commands and their NVS persistence.
- **Changes completed:** Removed the pending line-coding apply path and its counters; retained the latest host setting for `usb status`; updated the contract documentation.
- **Remaining work:** Target-hardware verification: acquire/release USB writer ownership after changing a host terminal's line coding and confirm UART1 remains at the configured framing.
- **Risks / things to remember:** Host terminal line-coding selectors no longer configure the physical RS-232 port; use `serial set`/`serial save` instead. `pio run` passed after the change.
### Handoff template
+1 -1
View File
@@ -85,7 +85,7 @@ Each client has a generation-safe ID. There can be one writer and multiple obser
| `usb counters` / `usb clear-counters` | Show or clear USB counters. |
| `usb request-writer` / `usb release-writer` | Request or release USB writer ownership. |
Opening `/dev/ttyACM*` with DTR asserted creates the `usb-cdc` broker client, starts UART1 if needed, and requests writer ownership. It becomes an observer if another client is writer. USB data is binary-transparent. Supported host line coding is 1101000000 baud, 7/8 data bits, none/odd/even parity, and 1/2 stop bits; settings apply only while USB owns the writer lease and are not saved automatically.
Opening `/dev/ttyACM*` with DTR asserted creates the `usb-cdc` broker client, starts UART1 if needed, and requests writer ownership. It becomes an observer if another client is writer. USB data is binary-transparent. The host's CDC line coding is shown by `usb status` for diagnostics only; it does not alter UART1. Configure physical baud rate, framing, flow control, and DTR explicitly with `serial` commands and persist them with `serial save`.
## Wi-Fi
+1 -1
View File
@@ -93,7 +93,7 @@ Implemented and hardware-validated:
- Automatic broker connection when the host opens the port with DTR asserted.
- Opportunistic writer acquisition with observer fallback.
- Binary-transparent bidirectional serial data.
- Supported host line-coding application while USB owns the writer lease.
- Host line-coding visibility for diagnostics; UART1 remains under explicit serial configuration control.
- Disconnect cleanup, bounded buffering, counters, and UART0 lifecycle controls.
### Phase 4 — Wi-Fi foundation