Add CTS and RTS flow-control tests
This commit is contained in:
@@ -138,6 +138,47 @@ DE-9 pin 7 RTS ─────> pin 2 RX
|
||||
|
||||
Run `loopback-b`. Together, configurations A and B exercise all three MAX3243 drivers and all five receivers.
|
||||
|
||||
### Configuration C: CTS transmit gating
|
||||
|
||||
Disconnect every external DE-9 cable or peer, power the ESP32 and breakout down, and remove every previous jumper. Confirm that the two jumpers below are the only connections to these RS-232 pins before powering up again.
|
||||
|
||||
| From driven output | To receiver input | Test purpose |
|
||||
|---|---|---|
|
||||
| DE-9 pin 3, `TX` | DE-9 pin 2, `RX` | Return UART1 transmitted data for exact comparison |
|
||||
| DE-9 pin 4, `DTR` | DE-9 pin 8, `CTS` | Let software-controlled DTR present inactive and active CTS states |
|
||||
|
||||
```text
|
||||
DE-9 pin 3 TX ─────> pin 2 RX
|
||||
DE-9 pin 4 DTR ─────> pin 8 CTS
|
||||
```
|
||||
|
||||
Run `cts-flow-test`. The test operates UART1 at 115200 baud with hardware CTS enabled and performs two phases:
|
||||
|
||||
1. DTR logic 1 produces CTS logic 1, the inactive/high state. The firmware queues 512 bytes and verifies that transmission does not complete and no byte reaches RX during a 250 ms observation period.
|
||||
2. DTR changes to logic 0, producing active/low CTS. The queued transmission must resume automatically, and all 512 bytes must return through RX without missing, extra, or corrupted data and without UART errors.
|
||||
|
||||
A buffered UART transmitter is used so the console command itself cannot deadlock while CTS is blocking transmission. The firmware does not manipulate the UART transmit queue between the blocked and resumed phases.
|
||||
|
||||
### Configuration D: RTS receive backpressure
|
||||
|
||||
Disconnect every external DE-9 cable or peer, power the ESP32 and breakout down, and remove every previous jumper. Confirm that the two jumpers below are the only connections to these RS-232 pins before powering up again.
|
||||
|
||||
| From driven output | To receiver input | Test purpose |
|
||||
|---|---|---|
|
||||
| DE-9 pin 4, `DTR` | DE-9 pin 2, `RX` | Carry UART2-generated test data into UART1 RX |
|
||||
| DE-9 pin 7, `RTS` | DE-9 pin 1, `DCD` | Return UART1 RTS through DCD to UART2 CTS |
|
||||
|
||||
```text
|
||||
UART2 TX / DE-9 pin 4 DTR ─────> pin 2 RX / UART1 RX
|
||||
UART1 RTS / DE-9 pin 7 RTS ─────> pin 1 DCD / UART2 CTS
|
||||
```
|
||||
|
||||
Run `rts-flow-test`. GPIO7 is temporarily routed from UART2 TX through the MAX3243 DTR driver. GPIO4 receives UART1 RTS through the DCD receiver and is simultaneously routed to UART2 CTS. This creates a complete hardware-controlled flow loop without an external serial peer.
|
||||
|
||||
The test queues 4096 bytes from UART2 but initially does not read UART1. UART1's receive ring eventually fills, its hardware FIFO crosses the configured threshold, and UART1 automatically deasserts RTS. That state passes through the physical pin 7 to pin 1 jumper and blocks UART2 through CTS. The firmware then drains UART1, which must automatically reassert RTS and allow UART2 to finish.
|
||||
|
||||
`UART_BUFFER_FULL` is expected during this deliberate pressure test. It means the UART ISR could not fit its current received-data batch into the software RX ring, confirming receive-side resource pressure. The driver preserves that batch while hardware RTS stops the sender. `UART_FIFO_OVF`, framing errors, parity errors, breaks, missing bytes, extra bytes, or data mismatches are failures.
|
||||
|
||||
### Manual voltage and polarity checks
|
||||
|
||||
With no DE-9 loopback jumpers installed, use the static `drivers` command and measure each driven output relative to DE-9 pin 5 (`GND`):
|
||||
@@ -163,8 +204,10 @@ Each output should be at a negative RS-232 voltage. Exact values vary with suppl
|
||||
5. Keep only the pin 3 to pin 2 jumper and run a basic test such as `uart-loopback 9600 8N1 256`.
|
||||
6. If that passes, run `uart-suite`.
|
||||
7. Power down, replace the jumpers with configuration B, power up, and run `loopback-b`.
|
||||
8. Power down, install configuration C, power up, and run `cts-flow-test`.
|
||||
9. Power down, install configuration D, power up, and run `rts-flow-test`.
|
||||
|
||||
RTS/CTS hardware-flow-control behavior is intentionally deferred until these static and UART loopback tests pass. During the current UART tests, RTS and CTS remain ordinary GPIO signals and UART1 flow control is disabled.
|
||||
RTS and CTS remain ordinary GPIO signals during static and basic UART loopback tests. Only the two dedicated flow-control commands hand them to UART peripherals. Every test shuts the MAX3243 down while changing GPIO-matrix routing and restores all outputs to static logic 1 afterward.
|
||||
|
||||
## Future hardware profiles
|
||||
|
||||
|
||||
Reference in New Issue
Block a user