Skip to content

ECUA UART: add alternative CDC-USB / LPUART1 - #73

Open
BenGardiner wants to merge 12 commits into
ToyotaInfoTech:mainfrom
BenGardiner:ecua-alt-transport
Open

BenGardiner wants to merge 12 commits into
ToyotaInfoTech:mainfrom
BenGardiner:ecua-alt-transport

Conversation

@BenGardiner

Copy link
Copy Markdown
Contributor

enables ECU A to use LPUART1 as an alternative command transport (e.g. for Renode simulation or hardware UART adapters) and connects it with ENABLE_ECUA_HOST_INTERACTION (see #72) so that internal CAN transmissions are forwarded over the active serial transport.

Testing included simulating 4-ECU RAMN in Re:node and connecting python-can to the set over LPUART1 over TCP (python-can slcan 'socket://') in J1939 mode

  • Simulated 4 ECUs (ECUA, ECUB, ECUC, ECUD) attached to canHub with ECUA.lpuart1 exposed via TCP socket port 29536.
  • Executed python-can SLCAN client (socket://127.0.0.1:29536):
    • Broadcast J1939 Address Claim request (0x18EAFFF1) was sent from client 0xF1.
    • Remote ECUs (0x13 Chassis, 0x21 Powertrain, 0x5A Body) responded and were forwarded.
    • Local ECU A (0x2A Headway) claimed its address and its transmitted frame was forwarded to the host over LPUART1

BenGardiner and others added 8 commits September 17, 2026 06:55
* Plan for skipping J1939db dependent tests in CI

Co-authored-by: BenGardiner <243321+BenGardiner@users.noreply.github.com>

* Dynamically skip J1939db tests in RecordingDescriber if file is missing

Co-authored-by: BenGardiner <243321+BenGardiner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: BenGardiner <243321+BenGardiner@users.noreply.github.com>
@github-actions

github-actions Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

🔨 Build & Macro Coverage Report

Default Builds — Hex File Sizes

ECU Debug (tag 15.0) Debug (tag 2.1.1) Release (tag 15.0) Release (tag 2.1.1)
ECUA 547 KiB (560658 bytes) 547 KiB (560658 bytes) 369 KiB (378431 bytes) 369 KiB (378378 bytes)
ECUB 363 KiB (372451 bytes) 363 KiB (372451 bytes) 216 KiB (222166 bytes) 216 KiB (221671 bytes)
ECUC 345 KiB (353325 bytes) 345 KiB (353325 bytes) 196 KiB (201593 bytes) 196 KiB (201082 bytes)
ECUD 354 KiB (363053 bytes) 354 KiB (363053 bytes) 204 KiB (209063 bytes) 203 KiB (208748 bytes)

Macro Coverage Build Results

Variant Macros Changed Result Warnings
ecua_lpuart1_transport +RAMN_SERIAL_CMD_TRANSPORT_LPUART1 −RAMN_SERIAL_CMD_TRANSPORT_USB_CDC ✅ Pass 5
gsusb +ENABLE_GSUSB ✅ Pass 5
gsusb_and_bb +ENABLE_GSUSB +ENABLE_BITBANG ✅ Pass 5
i2c +ENABLE_I2C ✅ Pass 5
j1939 +DEFAULT_TRAFFIC_MODE=TRAFFIC_MODE_J1939 ✅ Pass 5
j1939_showcase_mode +DEFAULT_TRAFFIC_MODE=TRAFFIC_MODE_J1939 +RAMN_SHOWCASE_MODE ✅ Pass 5
kwp +ENABLE_KWP ✅ Pass 5
no_debug −ENABLE_USB_DEBUG −ENABLE_JOYSTICK_CONTROLS −ENABLE_SCREEN −ENABLE_CHIP8 −GENERATE_RUNTIME_STATS ✅ Pass 5
no_dynamic_bitrate −ENABLE_DYNAMIC_BITRATE ✅ Pass 5
no_extras −ENABLE_J1979 −ENABLE_MINICTF −ENABLE_CHIP8 −ENABLE_SCREEN −ENABLE_SPI ✅ Pass 5
no_uds −ENABLE_UDS −ENABLE_UDS_REPROGRAMMING ✅ Pass 6
uart +ENABLE_UART −ENABLE_CDC −ENABLE_USB ✅ Pass 5
usb_autodetect +ENABLE_USB_AUTODETECT ✅ Pass 5
watchdog +WATCHDOG_ENABLE ✅ Pass 5

Source Code Compile Coverage

  • Total .c source lines: 22120
  • Lines compiled in ≥1 configuration: 20920 (~95%)
  • ENABLE_ macro coverage: 23/23 (100.0%) macros tested in both ON and OFF states
Full ENABLE_ Macro Coverage Table
# Macro Tested ON Tested OFF Covered
1 ENABLE_ADC default (ECUB, ECUC, ECUD) default (ECUA) ✅
2 ENABLE_BITBANG default (ECUA), variant: gsusb_and_bb default (ECUB, ECUC, ECUD) ✅
3 ENABLE_CDC default (ECUA) default (ECUB, ECUC, ECUD), variant: uart ✅
4 ENABLE_CHIP8 default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug, variant: no_extras ✅
5 ENABLE_DYNAMIC_BITRATE default (ECUA, ECUB, ECUC, ECUD) variant: no_dynamic_bitrate ✅
6 ENABLE_ECUA_HOST_INTERACTION default (ECUA) default (ECUB, ECUC, ECUD) ✅
7 ENABLE_GSUSB variant: gsusb, variant: gsusb_and_bb default (ECUA, ECUB, ECUC, ECUD) ✅
8 ENABLE_I2C variant: i2c default (ECUA, ECUB, ECUC, ECUD) ✅
9 ENABLE_J1979 default (ECUA, ECUB, ECUC, ECUD) variant: no_extras ✅
10 ENABLE_JOYSTICK_CONTROLS default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug ✅
11 ENABLE_KWP variant: kwp default (ECUA, ECUB, ECUC, ECUD) ✅
12 ENABLE_MINICTF default (ECUA, ECUD) default (ECUB, ECUC), variant: no_extras ✅
13 ENABLE_SCREEN default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug, variant: no_extras ✅
14 ENABLE_SPI default (ECUA, ECUD) default (ECUB, ECUC), variant: no_extras ✅
15 ENABLE_UART default (ECUA), variant: uart default (ECUB, ECUC, ECUD) ✅
16 ENABLE_UDS default (ECUA, ECUB, ECUC, ECUD) variant: no_uds ✅
17 ENABLE_UDS_REPROGRAMMING default (ECUA, ECUB, ECUC, ECUD) variant: no_uds ✅
18 ENABLE_USB default (ECUA) default (ECUB, ECUC, ECUD), variant: uart ✅
19 ENABLE_USB_AUTODETECT variant: usb_autodetect default (ECUA, ECUB, ECUC, ECUD) ✅
20 ENABLE_USB_DEBUG default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug ✅
21 ENABLE_XCP default (ECUB, ECUC, ECUD) default (ECUA) ✅
22 GENERATE_RUNTIME_STATS default (ECUA, ECUB, ECUC, ECUD) variant: no_debug ✅
23 WATCHDOG_ENABLE variant: watchdog default (ECUA, ECUB, ECUC, ECUD) ✅

BenGardiner and others added 3 commits September 20, 2026 14:50
… LPUART1 backend

- Add RAMN_SERIAL_CMD_TRANSPORT_USB_CDC / RAMN_SERIAL_CMD_TRANSPORT_LPUART1
  macros with compile-time XOR enforcement in ramn_config.h
- Create ramn_serial_cmd.h/.c: transport-agnostic send API with backend
  function table registration
- Refactor ramn_cdc.c to use RAMN_Serial_Send* instead of RAMN_USB_Send*
- Extend ramn_cdc.h/.c and ramn_dbc.c guards to compile for both CDC and UART transports
- Add UART lock/ASCII send functions to ramn_uart.h/.c for LPUART1 backend
- Update main.c: register serial backends, route LPUART1 commands through
  CLI/sLCAN processors, and guard CDC headers and structs for UART builds
- Guard ENABLE_USB_DEBUG to USB transport only

Co-authored-by: BenGardiner <243321+BenGardiner@users.noreply.github.com>
…T1 transport

- In RAMN_SendCANFunc, guard slcan frame forwarding with
  #if defined(ENABLE_CDC) || defined(ENABLE_UART)
- Replace RAMN_USB_SendFromTask with RAMN_Serial_SendFromTask so frames
  transmitted by ECU A itself are forwarded over whichever serial backend
  is active (USB CDC or LPUART1)
- Update comment in RAMN_ReceiveCANFunc noting USB/UART echo storm prevention
…guide

- Add ecua_lpuart1_transport build variant to CI matrix
- Document ECUA command transport selection (USB CDC XOR LPUART1) in customizing_guide.rst
- Mention selectable serial command transports in README.md

Co-authored-by: BenGardiner <243321+BenGardiner@users.noreply.github.com>
@BenGardiner

Copy link
Copy Markdown
Contributor Author

@CamilleTTT this PR is a culmination of #70 , #71 , #72 (and #73 itself). If you like the whole set you can just merge this one. Or if there are larger changes to be made in one you can pick and choose.

@BenGardiner

Copy link
Copy Markdown
Contributor Author

(also added docker run of the firmwares in a renode container and python-can runtime testing via slcan socket:// for any LPUART builds in the matrix)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants