Move RS-232 status under debug. Fix #2 from list.

This commit is contained in:
2026-08-31 03:45:38 +02:00
parent 2aafff25be
commit d9bd86bb84
8 changed files with 19 additions and 21 deletions
+1 -1
View File
@@ -137,7 +137,7 @@ This is a semantic map, not a complete file inventory. Start here, then read the
- Files: `src/board_pins.h`, `src/rs232_hw_test.{h,c}`, `src/local_ui_hw_test.{h,c}`, `src/status_led.{h,c}`
- Documentation: `docs/wiring.md`, `docs/electrical_tests.md`
- Called by: startup and `debug`/`status` commands
- Called by: startup and `debug` commands
- Dependencies: physical RS-232 owner, serial/display services, ESP-IDF GPIO/UART/I2C/LED drivers
- Ownership: RS-232 diagnostics refuse to run while the service owns the port; display diagnostics reuse `local_display`.
- Constraint: wiring and voltage assumptions are safety-relevant; verify target hardware before running diagnostics. RGB LED initialization is currently boot-fatal, and its colors report diagnostic state rather than aggregate firmware health.
+7 -7
View File
@@ -46,13 +46,13 @@ These observations should be checked when touching the relevant area; they are n
## Active Task
- **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.
- **Objective:** Keep UART1 configuration independent of USB CDC host line coding and move the Phase 0 RS-232 signal status command under `debug`.
- **Relevant files:** `src/usb_cdc_transport.{c,h}`, `src/usb_console.c`, `src/rs232_hw_test.c`, `src/console_completion.c`, related documentation.
- **Findings:** The USB transport converted cached CDC line coding into `serial_config_t` and called `serial_service_apply_config()` after writer acquisition. Separately, root `status` was a Phase 0 diagnostic that needed to claim the RS-232 port and therefore failed while the production serial service owned it.
- **Decision:** Treat CDC line coding as diagnostic metadata only. UART1 configuration remains exclusively controlled by explicit `serial` commands and their NVS persistence. Keep all Phase 0 RS-232 diagnostics, including signal status, under `debug`.
- **Changes completed:** Removed the pending line-coding apply path and its counters; retained the latest host setting for `usb status`. Replaced root `status` with `debug status`, updated completion and 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. Verify `debug status` works after `serial stop` and root `status` is unknown.
- **Risks / things to remember:** Host terminal line-coding selectors no longer configure the physical RS-232 port; use `serial set`/`serial save` instead. `debug status` remains ownership-protected and requires UART1 to be stopped. `pio run` passed after both changes.
### Handoff template
+1 -1
View File
@@ -8,7 +8,6 @@ UART0 and authenticated `admin` SSH sessions use the same registered command imp
|---|---|
| `memory` | Show free memory, minimum free memory, and largest blocks for internal RAM, DMA-capable RAM, and PSRAM. |
| `reboot` | Drain console output briefly and restart the ESP32. |
| `status` | Show quick MAX3243 signal state. |
## Role-based users
@@ -150,6 +149,7 @@ UART0 and admin SSH use shared whole-line Tab completion. A unique/common prefix
| Command | Description |
|---|---|
| `debug status` | Show MAX3243 driver, receiver, VLD, and shutdown states. It requires UART1 to be stopped. |
| `debug transceiver <enable|disable>` | Enable or shut down the MAX3243. |
| `debug drivers <tx 0|1> <dtr 0|1> <rts 0|1>` | Drive static TX, DTR, and RTS logic levels for measurement. |
| `debug loopback-a` / `debug loopback-b` | Test MAX3243 driver/receiver loopback configurations. |
+1 -1
View File
@@ -276,7 +276,7 @@ Each output should be negative. Exact voltages depend on supply, load, meter, an
## Recommended order
1. With no DE-9 jumpers, run `status`.
1. With no DE-9 jumpers and after `serial stop`, run `debug status`.
2. Measure output polarity with `debug drivers 0 0 0` and `debug drivers 1 1 1`.
3. Power down, install configuration A, power up, and run `debug loopback-a`.
4. Run `debug valid-test` with configuration A still installed.
+1 -1
View File
@@ -57,7 +57,7 @@ Implemented and hardware-validated:
- Hardware CTS transmit gating and RTS receive-backpressure tests.
- Exclusive RS-232 port ownership and fault-safe cleanup.
- RGB status indication for diagnostic state.
- Potentially disruptive tests isolated under the `debug` CLI submenu; top-level `status` retained.
- Phase 0 hardware diagnostics, including signal status, are isolated under the `debug` CLI submenu.
Detailed procedures are in [Electrical tests](electrical_tests.md) and [Hardware wiring](wiring.md).
+2 -2
View File
@@ -14,7 +14,7 @@ Upgrade a device that already has working HTTPS/SSH credentials and no `user_db`
2. Confirm exactly one `admin`-named account exists with role `user`, `bootstrapped=no`, no displayed password/salt/verifier, and no public keys.
3. Confirm the pre-upgrade credential still authenticates to HTTPS and SSH and that serial terminal behavior is unchanged.
4. Reboot and confirm `user status` reports the same account ID and authentication generation.
5. Confirm routine boot logs, `status`, `web status`, and `ssh status` contain no user password, verifier, salt, or raw public-key blob.
5. Confirm routine boot logs, `web status`, and `ssh status` contain no user password, verifier, salt, or raw public-key blob.
A transient failure reading the legacy web credential must not create or commit an empty user database. If a valid `user_db` blob already exists, it must still load without the legacy credential being readable.
@@ -130,7 +130,7 @@ Use one disposable `admin` and one disposable `user`. Keep UART0 attached throug
### 1. Route separation and normal shells
1. Connect as the normal user and confirm the existing broker-backed UART1 serial stream, broker client, and writer/observer behavior are unchanged.
2. Connect as the administrator and confirm the `admin@serial-tool>` prompt appears. Run `help`, `status`, `memory`, `serial status`, `wifi status`, `web status`, `broker status`, and `broker clients`. Compare representative output with UART0 and confirm both routes execute the same registered command implementations.
2. Connect as the administrator and confirm the `admin@serial-tool>` prompt appears. Run `help`, `memory`, `serial status`, `wifi status`, `web status`, `broker status`, and `broker clients`. Compare representative output with UART0 and confirm both routes execute the same registered command implementations.
3. From UART0 run `ssh sessions` and `broker clients`. The user session must show `route=broker`; the admin session must show `route=admin-console`, `broker=0`, `broker-role=n/a`, and no writer lease. The admin session must not start UART1 or alter broker client/writer counts merely by connecting.
### 2. Bounded command processing
+2 -1
View File
@@ -11,13 +11,14 @@
#include "linenoise/linenoise.h"
static const char *const s_root_candidates[] = {
"help", "status", "debug", "display", "serial", "broker", "usb", "user",
"help", "debug", "display", "serial", "broker", "usb", "user",
"wifi", "web", "ssh", "ping", "nslookup", "traceroute", "reboot", "memory",
};
/* Keep full-line candidate strings grouped by their registered root command. */
static const char *const s_completion_candidates[] = {
/* Hardware debug commands and safe fixed arguments. */
"debug status",
"debug transceiver",
"debug transceiver enable",
"debug transceiver disable",
+4 -7
View File
@@ -1579,6 +1579,7 @@ DEFINE_OWNED_COMMAND(rts_flow_test)
static void print_debug_usage(void)
{
printf("Usage:\n");
printf(" debug status\n");
printf(" debug transceiver <enable|disable>\n");
printf(" debug drivers <TX 0|1> <DTR 0|1> <RTS 0|1>\n");
printf(" debug loopback-a|loopback-b|valid-test\n");
@@ -1595,6 +1596,9 @@ static int command_debug(int argc, char **argv)
}
/* Existing handlers expect their own command name in argv[0]. */
if (strcmp(argv[1], "status") == 0) {
return command_status(argc - 1, argv + 1);
}
if (strcmp(argv[1], "transceiver") == 0) {
return command_transceiver(argc - 1, argv + 1);
}
@@ -1647,13 +1651,6 @@ esp_err_t rs232_hw_test_register_console_commands(void)
}
const esp_console_cmd_t commands[] = {
{
.command = "status",
.help = "Show MAX3243 driver, receiver, VLD, and shutdown states",
.hint = NULL,
.func = &command_status,
.argtable = NULL,
},
{
.command = "debug",
.help = "Low-level RS-232 and local-UI hardware diagnostics; run 'debug' for subcommands",