|
ether2ser 0.1.0
Ethernet <-> synchronous V.24 bridge firmware for RP2040 + W5500
|
Ethernet ↔ synchronous V.24 (RS-232/V.28) bridge firmware for RP2040 + W5500 (W55RP20-EVB-PICO).
What It Does
Hardware
pio/.Repository Layout
src/ firmware sourcessrc/system app context, event loop/dispatch, CLI, config, loggingsrc/drivers W5500, GPIO, TX/RX driverssrc/protocol HDLC encode/decode/syncsrc/examples example firmware targetsexternal/ submodules (WIZnet-PICO-C, Unity)pcb/ hardware design filesDependencies
PICO_SDK_PATH set)arm-none-eabi-*)picotool for flash targets (optional but recommended)Setup
Note: setup_toolchain.sh is Arch Linux specific and uses sudo.
Build (firmware)
Flash
build/ after a successful build.Usage
help for available commands.src/drivers/w5500_driver.h.Status Output
status command prints live pipeline diagnostics.General
| Name | Meaning | Debug hint |
|---|---|---|
Current Baudrate estimation | Measured RX clock frequency from the v24_rxc monitor pin. | If this is far from configured baud, debug physical clock/sampling before protocol logic. |
Traffic
| Name | Meaning | Debug hint |
|---|---|---|
Frames | Stage counters across the pipeline (udp_rx, hdlc_tx, hdlc_rx, udp_tx). | Compare columns to locate where frames are being lost. |
udp_rx | UDP frames accepted from Ethernet. | If low, issue is upstream/network side. |
hdlc_tx | Frames encoded and queued to serial TX. | udp_rx and hdlc_tx should track closely. |
hdlc_rx | HDLC frame candidates detected on serial RX. | Much larger than hdlc_tx usually means desync/false framing. |
udp_tx | Frames successfully decoded and sent via UDP. | Gap to hdlc_rx indicates decode/sync failures. |
Backlog | Gap metrics between stages. | tx->ready_gap grows when RX cannot keep up; ready->udp_gap grows on decode failures. |
tx->ready_gap | hdlc_tx - hdlc_rx. | Persistent growth means receive/framing lag. |
ready->udp_gap | hdlc_rx - udp_tx. | Persistent growth points at decode integrity issues. |
Serial | Cumulative byte counters on wire (rx_bytes, tx_bytes). | Large divergence indicates one direction not flowing cleanly. |
Rates | Per-second deltas from previous status. | First sample or very short interval can look inflated. |
Decode / Sync
| Name | Meaning | Debug hint |
|---|---|---|
Decode | Decoder outcomes (frame_ready, ok, fail). | fail near zero is expected in stable runs. |
frame_ready | HDLC candidates emitted by sync layer. | If this overshoots TX by a lot, suspect framing alignment/noise. |
ok | Successful decode + CRC validation. | Should track udp_tx. |
fail | Failed decode attempts. | Use FailReason to identify root cause. |
FailReason | Breakdown (invalid, short, long, unstuff, crc). | unstuff dominance suggests bitstream corruption/alignment; crc points to data corruption after framing. |
SyncState | Current sync FSM state (HUNTING, SYNCING, SYNCED). | Long time in SYNCING/SYNCED with low progress can indicate stuck candidate flow. |
SyncWait | Lookahead waits for cross-byte alignment in SYNCING/SYNCED. | Fast growth indicates frequent boundary stalls. |
SyncMaint | Maintenance counters (consume, hardcap_events, hardcap_bytes). | hardcap_* should remain near zero in healthy operation. |
Resync | Recovery reason counters (idle, hard, no_progress). | Spikes indicate unstable decode path or over-aggressive thresholds. |
Accum | Internal accumulator live state (pos, proc, state, off, candidate fields). | Non-zero pos/proc for long periods without progress indicates parser stall. |
RX Health | RX path health (acc_pos_max, rx_fifo_stall, rx_drop_acc_full). | Rising rx_fifo_stall indicates service starvation; rising rx_drop_acc_full means accumulator backpressure. |
Buffers
| Name | Meaning | Debug hint |
|---|---|---|
TX Queue | Current TX queue occupancy (used/capacity, active). | used near capacity indicates sustained overload. |
used | Number of queued TX frames. | Trend matters more than instantaneous value. |
active | 1 if one frame is currently being drained to TX FIFO. | active=0 with used>0 indicates drain path issue. |
HighWater | Peak occupancy since boot (tx, event, log). | Useful to size buffers and detect near-overflow phases. |
Drops | Cumulative dropped items (tx, event, log). | Any non-zero drop counter indicates data/control loss. |
Recons | Current reconstructed frame length pending decode. | Large lingering values can indicate stuck/incomplete candidate handling. |
PIO TX | TX PIO stall flag state. | Sticky hardware indicator; useful to correlate with underfeeding/transmit pacing. |
UDP Test Scripts
tests/udp_cli_sender.shsocat.UDP-DATAGRAM:<ip>:<port>,broadcast; edit DEST_IP and DEST_PORT inside the script before use.tests/send_receive.pysender, receiver, or both mode.tests/stress.pyHOST, PORT, SIZE, RATE, DURATION).tests/udp_stress.pysender, receiver, or both (loopback) mode.baudrate / (frame_size * 8), supports random frame sizes (--min-size to --size), start/end markers, monotonic sequence tracking, loss stats, configurable idle timeout, and optional minimum inter-frame delay (--min-delay-ms).tests/image_send_receive.py (requested as tests/image_send_and_receive.py)256x256, chunks with sequence + last-frame flag; receiver reassembles and writes PNG.--preview to open the image after complete reception.Tests
Static Analysis
check_clang_tidy requires clang-tidy in PATH.check_cppcheck requires cppcheck in PATH.Documentation (Doxygen)
build/docs/doxygen/html/index.htmlCoverage + Documentation
build-tests/docs/doxygen/html/index.htmlbuild-tests/docs/doxygen/html/coverage.htmlindex.html), use the Related Pages entry Coverage Report (or open coverage.html directly).License Apache-2.0 (see LICENSE).