Skip to content

[WIP] gs_usb: error frames and FD#38

Draft
BenGardiner wants to merge 7 commits intoToyotaInfoTech:mainfrom
BenGardiner:gs_usb-errors-and-fd
Draft

[WIP] gs_usb: error frames and FD#38
BenGardiner wants to merge 7 commits intoToyotaInfoTech:mainfrom
BenGardiner:gs_usb-errors-and-fd

Conversation

@BenGardiner
Copy link
Contributor

No description provided.

@BenGardiner BenGardiner marked this pull request as draft March 2, 2026 21:26
@BenGardiner BenGardiner force-pushed the gs_usb-errors-and-fd branch from a25ec5c to 4d9223c Compare March 3, 2026 13:47
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

🔨 Build & Macro Coverage Report

Default Builds — Hex File Sizes

ECU Debug (tag 15.0) Release (tag 15.0)
ECUA 466 KiB (477828 bytes) 302 KiB (310133 bytes)
ECUB 330 KiB (338327 bytes) 193 KiB (198496 bytes)
ECUC 310 KiB (317995 bytes) 173 KiB (177247 bytes)
ECUD 320 KiB (328480 bytes) 180 KiB (184649 bytes)

Macro Coverage Build Results

ECU Variant Macros Changed Result Hex Size Warnings
ECUA gsusb +ENABLE_GSUSBENABLE_CDC ✅ Pass 267 KiB 0
ECUA gsusb-fdcan +ENABLE_GSUSB +ENABLE_GSUSB_CANFDENABLE_CDC ✅ Pass 268 KiB 0
ECUA no_debug ENABLE_USB_DEBUGENABLE_JOYSTICK_CONTROLSENABLE_SCREENENABLE_CHIP8GENERATE_RUNTIME_STATS ✅ Pass 211 KiB 0
ECUA no_extras ENABLE_J1979ENABLE_MINICTFENABLE_CHIP8ENABLE_SCREENENABLE_SPI ✅ Pass 221 KiB 0
ECUA no_uds ENABLE_UDSENABLE_UDS_REPROGRAMMING ✅ Pass 260 KiB 0
ECUB kwp +ENABLE_KWP ✅ Pass 196 KiB 0
ECUB no_dynamic_bitrate ENABLE_DYNAMIC_BITRATE ✅ Pass 193 KiB 0
ECUB watchdog +WATCHDOG_ENABLE ✅ Pass 194 KiB 0
ECUC uart +ENABLE_UART ✅ Pass 189 KiB 0

Source Code Compile Coverage

  • Total .c source lines: 17624
  • Lines compiled in ≥1 configuration: 16416 (~93%)
  • ENABLE_ macro coverage: 20/22 (90.9%) 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_CDC default (ECUA) default (ECUB, ECUC, ECUD), variant: gsusb (ECUA), variant: gsusb-fdcan (ECUA)
3 ENABLE_CHIP8 default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug (ECUA), variant: no_extras (ECUA)
4 ENABLE_DYNAMIC_BITRATE default (ECUA, ECUB, ECUC, ECUD) variant: no_dynamic_bitrate (ECUB)
5 ENABLE_GSUSB variant: gsusb (ECUA), variant: gsusb-fdcan (ECUA) default (ECUA, ECUB, ECUC, ECUD)
6 ENABLE_GSUSB_CANFD variant: gsusb-fdcan (ECUA) default (ECUA, ECUB, ECUC, ECUD)
7 ENABLE_I2C default (ECUA, ECUB, ECUC, ECUD)
8 ENABLE_J1979 default (ECUA, ECUB, ECUC, ECUD) variant: no_extras (ECUA)
9 ENABLE_JOYSTICK_CONTROLS default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug (ECUA)
10 ENABLE_KWP variant: kwp (ECUB) default (ECUA, ECUB, ECUC, ECUD)
11 ENABLE_MINICTF default (ECUA, ECUD) default (ECUB, ECUC), variant: no_extras (ECUA)
12 ENABLE_SCREEN default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug (ECUA), variant: no_extras (ECUA)
13 ENABLE_SPI default (ECUA, ECUD) default (ECUB, ECUC), variant: no_extras (ECUA)
14 ENABLE_UART variant: uart (ECUC) default (ECUA, ECUB, ECUC, ECUD)
15 ENABLE_UDS default (ECUA, ECUB, ECUC, ECUD) variant: no_uds (ECUA)
16 ENABLE_UDS_REPROGRAMMING default (ECUA, ECUB, ECUC, ECUD) variant: no_uds (ECUA)
17 ENABLE_USB default (ECUA) default (ECUB, ECUC, ECUD)
18 ENABLE_USB_AUTODETECT default (ECUA, ECUB, ECUC, ECUD)
19 ENABLE_USB_DEBUG default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug (ECUA)
20 ENABLE_XCP default (ECUB, ECUC, ECUD) default (ECUA)
21 GENERATE_RUNTIME_STATS default (ECUA, ECUB, ECUC, ECUD) variant: no_debug (ECUA)
22 WATCHDOG_ENABLE variant: watchdog (ECUB) default (ECUA, ECUB, ECUC, ECUD)

@BenGardiner
Copy link
Contributor Author

@CamilleTTT that PR #39 worked. The github actions are fixed and see above for the results of the macro matrix coverage stuff.

@BenGardiner
Copy link
Contributor Author

@CamilleTTT also check out the results of the CI runs on main branch: e.g. https://github.com/ToyotaInfoTech/RAMN/actions/runs/22617100240

Fix gs_usb interface shortcomings:
* data bitrate init
* endpoint error check
* marshal/unmarshal frame offsets
* vendor request parsing
* add DLC conversion functions
* add CAN-FD feature flags
Add RAMN_GSUSB_SendErrorFrame() that constructs SocketCAN error frames
from FDCAN error state (bus off, error passive/warning, protocol errors)
and sends them through the gs_usb interface.

- Map FDCAN BusOff to CAN_ERR_BUSOFF
- Map FDCAN ErrorPassive/Warning to CAN_ERR_CRTL with data[1] flags
- Map FDCAN protocol errors (stuff, form, ack, bit, CRC) to CAN_ERR_PROT
- Call from RAMN_ErrorTaskFunc when ENABLE_GSUSB is active
- Remove "Error frames are not reported" from ramn_config.h limitations
- Remove TODO comment from main.c
Enable CAN-FD frame handling through the gs_usb (candlelight/SocketCAN)
interface, controlled by the host via GS_CAN_MODE_FD flag:

- Add GS_CAN_FLAG_FD/BRS/ESI frame flag defines per gs_usb protocol
- Advertise GS_CAN_FEATURE_FD in device capabilities
- Handle GS_CAN_MODE_FD in breq_set_mode to set enable_fdcan
- Update RAMN_GSUSB_ProcessRX to accept FD frames with FD/BRS/ESI flags
- Update RAMN_GSUSB_ProcessTX to set FD/BRS flags on TX echo frames
- Update RAMN_RxTask2Func TX path to decode FD/BRS/ESI flags from host
- Fix marshal/unmarshal to use FDCAN_ConvertToActual for data copy size
  (DLC codes 9-15 map to 12-64 bytes, not 9-15 bytes)
- Remove "CAN-FD is not supported" from ramn_config.h limitations
@BenGardiner BenGardiner force-pushed the gs_usb-errors-and-fd branch from 4d9223c to a25c12f Compare March 3, 2026 15:12
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.

1 participant