Skip to content

DroneCAN: Add node table, CLI status, and MSP2 node query commands#11527

Open
daijoubu wants to merge 3 commits intoiNavFlight:maintenance-10.xfrom
daijoubu:feature/msp-dronecan-support
Open

DroneCAN: Add node table, CLI status, and MSP2 node query commands#11527
daijoubu wants to merge 3 commits intoiNavFlight:maintenance-10.xfrom
daijoubu:feature/msp-dronecan-support

Conversation

@daijoubu
Copy link
Copy Markdown
Contributor

@daijoubu daijoubu commented May 1, 2026

Summary

  • Add DroneCAN status to status CLI command — shows nodeID, bitrate, bus state, and detected node count
  • Add node table infrastructuredronecanNodeInfo_t struct, nodeTable[32], updated handle_NodeStatus() to upsert per-node data, and new accessors (dronecanGetState(), dronecanGetNodeCount(), dronecanGetNode(), dronecanGetBitrateKbps())
  • Add MSP2_INAV_DRONECAN_NODES (0x2042) — returns count and status of all detected DroneCAN nodes
  • Add MSP2_INAV_DRONECAN_NODE_INFO (0x2043) — returns full detail for a single node by ID
  • Update MSP docs JSON and regenerate README — new messages documented in docs/development/msp/
  • Update DroneCAN docsDroneCAN.md and DroneCAN-Driver.md updated to cover node table, CLI output, and MSP commands

These MSP commands are the prerequisite for DroneCAN support in the Configurator UI (feature-dronecan-configurator-tab).

Test plan

  • Build cleanly for MATEKF765SE (zero errors, zero warnings)
  • Flash MATEKF765SE with DroneCAN battery monitor on bus
  • Verify status CLI shows correct nodeID, bitrate, and node count
  • Verify MSP2_INAV_DRONECAN_NODES returns the battery monitor node (health=OK, mode=OPERATIONAL)
  • Verify MSP2_INAV_DRONECAN_NODE_INFO returns correct data for node ID
  • Verify MSP2_INAV_DRONECAN_NODE_INFO returns empty response for unknown node ID
  • Verify targets without USE_DRONECAN build cleanly.

@qodo-code-review
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Add DroneCAN node table, MSP node query commands, and CLI status output

✨ Enhancement

Grey Divider

Walkthroughs

Description
  This description is generated by an AI tool. It may have inaccuracies
• Add DroneCAN node table infrastructure with dronecanNodeInfo_t struct and accessor functions
• Implement two new MSP2 commands (0x2042, 0x2043) for querying detected DroneCAN nodes
• Add DroneCAN status output to CLI status command showing nodeID, bitrate, bus state, and node
  count
• Update DroneCAN documentation with node table, MSP commands, and CLI diagnostics
Diagram
flowchart LR
  NodeStatus["NodeStatus Messages"] -->|upsert| NodeTable["Node Table<br/>nodeTable[32]"]
  NodeTable -->|dronecanGetNode| Accessor["Accessor Functions"]
  Accessor -->|dronecanGetNodeCount| CLI["CLI Status Command"]
  Accessor -->|dronecanGetState| CLI
  Accessor -->|dronecanGetBitrateKbps| CLI
  Accessor -->|dronecanGetNode| MSP["MSP2 Commands<br/>0x2042/0x2043"]
  CLI -->|display| User["User Output"]
  MSP -->|reply| Configurator["Configurator/GCS"]
Loading

Grey Divider

File Changes

1. src/main/drivers/dronecan/dronecan.h ✨ Enhancement +26/-3

Define node table structures and accessor functions

src/main/drivers/dronecan/dronecan.h


2. src/main/drivers/dronecan/dronecan.c ✨ Enhancement +64/-47

Implement node table population and accessor functions

src/main/drivers/dronecan/dronecan.c


3. src/main/fc/fc_msp.c ✨ Enhancement +54/-0

Add MSP2 DroneCAN node query command handlers

src/main/fc/fc_msp.c


View more (107)
4. src/main/fc/cli.c ✨ Enhancement +13/-0

Add DroneCAN status output to CLI status command

src/main/fc/cli.c


5. src/main/msp/msp_protocol_v2_inav.h ⚙️ Configuration changes +3/-0

Define MSP2 DroneCAN command codes

src/main/msp/msp_protocol_v2_inav.h


6. docs/development/msp/README.md 📝 Documentation +59/-1

Document MSP2 DroneCAN node query commands

docs/development/msp/README.md


7. docs/development/msp/msp_messages.json 📝 Documentation +134/-0

Add MSP2 DroneCAN command specifications to JSON schema

docs/development/msp/msp_messages.json


8. docs/DroneCAN-Driver.md 📝 Documentation +75/-2

Document node table, accessors, and MSP command integration

docs/DroneCAN-Driver.md


9. docs/DroneCAN.md 📝 Documentation +34/-0

Add diagnostics section with CLI and MSP command examples

docs/DroneCAN.md


10. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h Additional files +0/-3175

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h


11. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32_assert_template.h Additional files +0/-75

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32_assert_template.h


12. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h Additional files +0/-267

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h


13. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_adc.h Additional files +0/-860

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_adc.h


14. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_adc_ex.h Additional files +0/-426

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_adc_ex.h


15. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_can.h Additional files +0/-787

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_can.h


16. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cec.h Additional files +0/-747

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cec.h


17. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_conf_template.h Additional files +0/-459

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_conf_template.h


18. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h Additional files +0/-428

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h


19. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_crc.h Additional files +0/-249

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_crc.h


20. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cryp.h Additional files +0/-1162

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cryp.h


21. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cryp_ex.h Additional files +0/-295

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cryp_ex.h


22. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dac.h Additional files +0/-414

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dac.h


23. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dac_ex.h Additional files +0/-201

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dac_ex.h


24. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dcmi.h Additional files +0/-537

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dcmi.h


25. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dcmi_ex.h Additional files +0/-230

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dcmi_ex.h


26. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h Additional files +0/-214

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h


27. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dfsdm.h Additional files +0/-1060

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dfsdm.h


28. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h Additional files +0/-822

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h


29. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma2d.h Additional files +0/-577

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma2d.h


30. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h Additional files +0/-122

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h


31. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dsi.h Additional files +0/-1242

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dsi.h


32. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_eth.h Additional files +0/-2183

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_eth.h


33. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h Additional files +0/-446

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h


34. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h Additional files +0/-1084

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h


35. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h Additional files +0/-97

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h


36. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_fmpi2c.h Additional files +0/-720

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_fmpi2c.h


37. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_fmpi2c_ex.h Additional files +0/-163

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_fmpi2c_ex.h


38. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h Additional files +0/-327

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h


39. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h Additional files +0/-1592

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h


40. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_hash.h Additional files +0/-451

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_hash.h


41. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_hash_ex.h Additional files +0/-200

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_hash_ex.h


42. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_hcd.h Additional files +0/-262

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_hcd.h


43. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h Additional files +0/-651

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h


44. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c_ex.h Additional files +0/-139

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c_ex.h


45. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h Additional files +0/-543

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h


46. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s_ex.h Additional files +0/-191

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s_ex.h


47. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_irda.h Additional files +0/-604

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_irda.h


48. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_iwdg.h Additional files +0/-239

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_iwdg.h


49. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_lptim.h Additional files +0/-763

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_lptim.h


50. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_ltdc.h Additional files +0/-649

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_ltdc.h


51. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_ltdc_ex.h Additional files +0/-102

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_ltdc_ex.h


52. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_mmc.h Additional files +0/-726

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_mmc.h


53. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_nand.h Additional files +0/-358

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_nand.h


54. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_nor.h Additional files +0/-305

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_nor.h


55. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pccard.h Additional files +0/-266

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pccard.h


56. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd.h Additional files +0/-343

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd.h


57. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd_ex.h Additional files +0/-133

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd_ex.h


58. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h Additional files +0/-449

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h


59. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h Additional files +0/-372

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h


60. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_qspi.h Additional files +0/-785

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_qspi.h


61. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h Additional files +0/-1461

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h


62. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h Additional files +0/-7113

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h


63. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rng.h Additional files +0/-369

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rng.h


64. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rtc.h Additional files +0/-833

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rtc.h


65. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rtc_ex.h Additional files +0/-1029

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rtc_ex.h


66. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_sai.h Additional files +0/-866

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_sai.h


67. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_sai_ex.h Additional files +0/-134

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_sai_ex.h


68. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_sd.h Additional files +0/-725

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_sd.h


69. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_sdram.h Additional files +0/-197

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_sdram.h


70. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_smartcard.h Additional files +0/-687

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_smartcard.h


71. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spdifrx.h Additional files +0/-555

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spdifrx.h


72. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h Additional files +0/-587

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h


73. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_sram.h Additional files +0/-208

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_sram.h


74. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h Additional files +0/-1773

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h


75. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h Additional files +0/-370

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h


76. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h Additional files +0/-794

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h


77. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_usart.h Additional files +0/-592

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_usart.h


78. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_wwdg.h Additional files +0/-283

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_wwdg.h


79. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_adc.h Additional files +0/-4692

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_adc.h


80. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_bus.h Additional files +0/-2126

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_bus.h


81. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_cortex.h Additional files +0/-658

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_cortex.h


82. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_crc.h Additional files +0/-212

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_crc.h


83. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dac.h Additional files +0/-1440

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dac.h


84. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dma.h Additional files +0/-2878

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dma.h


85. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dma2d.h Additional files +0/-1851

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dma2d.h


86. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_exti.h Additional files +0/-974

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_exti.h


87. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_fmc.h Additional files +0/-1421

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_fmc.h


88. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_fsmc.h Additional files +0/-1051

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_fsmc.h


89. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_gpio.h Additional files +0/-1000

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_gpio.h


90. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_i2c.h Additional files +0/-1910

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_i2c.h


91. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_iwdg.h Additional files +0/-329

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_iwdg.h


92. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_lptim.h Additional files +0/-0

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_lptim.h


93. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_pwr.h Additional files +0/-0

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_pwr.h


94. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rcc.h Additional files +0/-0

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rcc.h


95. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rng.h Additional files +0/-0

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rng.h


96. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rtc.h Additional files +0/-3850

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rtc.h


97. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_sdmmc.h Additional files +0/-1135

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_sdmmc.h


98. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_spi.h Additional files +0/-2038

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_spi.h


99. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_system.h Additional files +0/-1726

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_system.h


100. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_tim.h Additional files +0/-3971

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_tim.h


101. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usart.h Additional files +0/-2539

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usart.h


102. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usb.h Additional files +0/-477

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usb.h


103. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_utils.h Additional files +0/-327

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_utils.h


104. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_wwdg.h Additional files +0/-342

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_wwdg.h


105. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c Additional files +0/-556

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c


106. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c Additional files +0/-1703

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c


107. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c Additional files +0/-1116

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c


108. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_can.c Additional files +0/-1683

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_can.c


109. lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cec.c Additional files +0/-673

...

lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cec.c


110. Additional files not shown Additional files +0/-0

...

Additional files not shown


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented May 1, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1)

Grey Divider


Action required

1. MSP2_INAV_DRONECAN_NODES buffer overflow 📘 Rule violation ⛨ Security
Description
The new MSP2_INAV_DRONECAN_NODES reply writes nodeCount records to dst without checking
remaining buffer space, so a full 32-node table (1 + 32*30 = 961 bytes) can exceed the fixed MSP out
buffer and corrupt memory. This violates the requirement to validate protocol payload sizes before
parsing/serialization.
Code

src/main/fc/fc_msp.c[R1774-1788]

+    case MSP2_INAV_DRONECAN_NODES:
+        {                                                                                                         
+            uint8_t count = dronecanGetNodeCount();                                         
+            sbufWriteU8(dst, count);                                                                              
+            for (uint8_t i = 0; i < count; i++) {
+                const dronecanNodeInfo_t *node = dronecanGetNode(i);                                              
+                sbufWriteU8(dst, node->nodeID);                                             
+                sbufWriteU8(dst, node->health);                                                                   
+                sbufWriteU8(dst, node->mode);                                               
+                sbufWriteU32(dst, node->uptime_sec);                                                              
+                sbufWriteU16(dst, node->vendor_status_code);                                
+                sbufWriteU32(dst, node->last_seen_ms);                                                            
+                sbufWriteU8(dst, node->name_len);
+                sbufWriteData(dst, node->name, 16);                                                               
+            }                                                                                                     
Evidence
The compliance rule requires validating protocol payload sizes; here the response size scales with
externally influenced nodeCount but sbufWrite*/sbufWriteData perform no bounds checks. The MSP
reply buffer is a fixed stack array sized by MSP_PORT_OUTBUF_SIZE (512 by default), so the
unbounded loop can write past the end when many nodes are present.

src/main/fc/fc_msp.c[1774-1788]
src/main/msp/msp_serial.h[59-66]
src/main/msp/msp_serial.c[394-401]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`MSP2_INAV_DRONECAN_NODES` serializes `nodeCount` node records without verifying that the MSP reply buffer (`dst`) has enough remaining capacity, which can overflow the fixed `MSP_PORT_OUTBUF_SIZE` out buffer.

## Issue Context
- `sbufWriteU8/U16/U32` and `sbufWriteData` do not perform bounds checking.
- Default MSP out buffer is `MSP_PORT_OUTBUF_SIZE` (512 unless `USE_FLASHFS`).
- Worst-case payload is `1 + nodeCount * 30` bytes (per-node record is 30 bytes in current implementation).

## Fix Focus Areas
- src/main/fc/fc_msp.c[1774-1788]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Wrong MSP error result 🐞 Bug ≡ Correctness
Description
MSP2_INAV_DRONECAN_NODE_INFO returns MSP_RESULT_ERROR/MSP_RESULT_ACK from a bool-returning function
and never updates *ret, so “node not found” (and malformed request) can be treated as handled but
still replied as ACK. This breaks the documented protocol behavior and can cause clients to
interpret an empty/partial payload as success.
Code

src/main/fc/fc_msp.c[R4286-4308]

+     case MSP2_INAV_DRONECAN_NODE_INFO:
+        {
+            if (sbufBytesRemaining(src) < 1) {
+                return MSP_RESULT_ERROR;                                                                          
+            }
+            uint8_t nodeId = sbufReadU8(src);                                                                     
+            uint8_t count = dronecanGetNodeCount();                                         
+            for (uint8_t i = 0; i < count; i++) {                                                                 
+                const dronecanNodeInfo_t *node = dronecanGetNode(i);
+                if (node->nodeID == nodeId) {                                                                     
+                    sbufWriteU8(dst, node->nodeID);                                                               
+                    sbufWriteU8(dst, node->health);
+                    sbufWriteU8(dst, node->mode);                                                                 
+                    sbufWriteU32(dst, node->uptime_sec);                                    
+                    sbufWriteU16(dst, node->vendor_status_code);
+                    sbufWriteU32(dst, node->last_seen_ms);
+                    sbufWriteU8(dst, node->name_len);
+                    sbufWriteData(dst, node->name, 32);
+                    return MSP_RESULT_ACK;
+                }
+            }
+            return MSP_RESULT_ERROR;
+        }
Evidence
mspFCProcessInOutCommand() is a bool-returning dispatcher that must set the MSP result via the ret
out-param; returning MSP_RESULT_ERROR (-1) is still “true” in C and bypasses the fallback path,
leaving ret unchanged (initialized to ACK). This contradicts the docs which explicitly require
MSP_RESULT_ERROR when the node is not present.

src/main/fc/fc_msp.c[4279-4310]
src/main/fc/fc_msp.c[4826-4853]
docs/development/msp/msp_messages.json[9950-9952]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`mspFCProcessInOutCommand()` returns `bool` (handled/unhandled) and uses the `mspResult_e *ret` out-param to communicate ACK vs ERROR. The new `MSP2_INAV_DRONECAN_NODE_INFO` case incorrectly `return`s `MSP_RESULT_*` values directly and never assigns `*ret`, causing error cases (e.g. unknown node ID) to be replied as ACK.

### Issue Context
`mspFcProcessCommand()` initializes `ret = MSP_RESULT_ACK` and only changes it if `mspFCProcessInOutCommand()` writes to `*ret`. Returning `MSP_RESULT_ERROR` (-1) from a `bool` function is still truthy and prevents the fallback path, so the reply result remains ACK.

### Fix Focus Areas
- src/main/fc/fc_msp.c[4273-4310]
- src/main/fc/fc_msp.c[4826-4853]

### Implementation notes
- In the `MSP2_INAV_DRONECAN_NODE_INFO` case:
 - Replace `return MSP_RESULT_ERROR;` with `*ret = MSP_RESULT_ERROR; break;`
 - Replace `return MSP_RESULT_ACK;` with `*ret = MSP_RESULT_ACK; break;`
 - Keep the function’s final `return true;` behavior for handled commands.
- Ensure the “not found” path sets `*ret = MSP_RESULT_ERROR` (per docs) and does not accidentally return ACK.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@daijoubu daijoubu force-pushed the feature/msp-dronecan-support branch from 051da24 to a5e4298 Compare May 1, 2026 02:28
@daijoubu daijoubu force-pushed the feature/msp-dronecan-support branch from a5e4298 to 3ce50c5 Compare May 1, 2026 02:31
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

Test firmware build ready — commit 3ce50c5

Download firmware for PR #11527

234 targets built. Find your board's .hex file by name on that page (e.g. MATEKF405SE.hex). Files are individually downloadable — no GitHub login required.

Development build for testing only. Use Full Chip Erase when flashing.

Comment thread src/main/fc/fc_msp.c
Comment on lines +1774 to +1788
case MSP2_INAV_DRONECAN_NODES:
{
uint8_t count = dronecanGetNodeCount();
sbufWriteU8(dst, count);
for (uint8_t i = 0; i < count; i++) {
const dronecanNodeInfo_t *node = dronecanGetNode(i);
sbufWriteU8(dst, node->nodeID);
sbufWriteU8(dst, node->health);
sbufWriteU8(dst, node->mode);
sbufWriteU32(dst, node->uptime_sec);
sbufWriteU16(dst, node->vendor_status_code);
sbufWriteU32(dst, node->last_seen_ms);
sbufWriteU8(dst, node->name_len);
sbufWriteData(dst, node->name, 16);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. msp2_inav_dronecan_nodes buffer overflow 📘 Rule violation ⛨ Security

The new MSP2_INAV_DRONECAN_NODES reply writes nodeCount records to dst without checking
remaining buffer space, so a full 32-node table (1 + 32*30 = 961 bytes) can exceed the fixed MSP out
buffer and corrupt memory. This violates the requirement to validate protocol payload sizes before
parsing/serialization.
Agent Prompt
## Issue description
`MSP2_INAV_DRONECAN_NODES` serializes `nodeCount` node records without verifying that the MSP reply buffer (`dst`) has enough remaining capacity, which can overflow the fixed `MSP_PORT_OUTBUF_SIZE` out buffer.

## Issue Context
- `sbufWriteU8/U16/U32` and `sbufWriteData` do not perform bounds checking.
- Default MSP out buffer is `MSP_PORT_OUTBUF_SIZE` (512 unless `USE_FLASHFS`).
- Worst-case payload is `1 + nodeCount * 30` bytes (per-node record is 30 bytes in current implementation).

## Fix Focus Areas
- src/main/fc/fc_msp.c[1774-1788]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread src/main/fc/fc_msp.c
Comment on lines +4286 to +4308
case MSP2_INAV_DRONECAN_NODE_INFO:
{
if (sbufBytesRemaining(src) < 1) {
return MSP_RESULT_ERROR;
}
uint8_t nodeId = sbufReadU8(src);
uint8_t count = dronecanGetNodeCount();
for (uint8_t i = 0; i < count; i++) {
const dronecanNodeInfo_t *node = dronecanGetNode(i);
if (node->nodeID == nodeId) {
sbufWriteU8(dst, node->nodeID);
sbufWriteU8(dst, node->health);
sbufWriteU8(dst, node->mode);
sbufWriteU32(dst, node->uptime_sec);
sbufWriteU16(dst, node->vendor_status_code);
sbufWriteU32(dst, node->last_seen_ms);
sbufWriteU8(dst, node->name_len);
sbufWriteData(dst, node->name, 32);
return MSP_RESULT_ACK;
}
}
return MSP_RESULT_ERROR;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Wrong msp error result 🐞 Bug ≡ Correctness

MSP2_INAV_DRONECAN_NODE_INFO returns MSP_RESULT_ERROR/MSP_RESULT_ACK from a bool-returning function
and never updates *ret, so “node not found” (and malformed request) can be treated as handled but
still replied as ACK. This breaks the documented protocol behavior and can cause clients to
interpret an empty/partial payload as success.
Agent Prompt
### Issue description
`mspFCProcessInOutCommand()` returns `bool` (handled/unhandled) and uses the `mspResult_e *ret` out-param to communicate ACK vs ERROR. The new `MSP2_INAV_DRONECAN_NODE_INFO` case incorrectly `return`s `MSP_RESULT_*` values directly and never assigns `*ret`, causing error cases (e.g. unknown node ID) to be replied as ACK.

### Issue Context
`mspFcProcessCommand()` initializes `ret = MSP_RESULT_ACK` and only changes it if `mspFCProcessInOutCommand()` writes to `*ret`. Returning `MSP_RESULT_ERROR` (-1) from a `bool` function is still truthy and prevents the fallback path, so the reply result remains ACK.

### Fix Focus Areas
- src/main/fc/fc_msp.c[4273-4310]
- src/main/fc/fc_msp.c[4826-4853]

### Implementation notes
- In the `MSP2_INAV_DRONECAN_NODE_INFO` case:
  - Replace `return MSP_RESULT_ERROR;` with `*ret = MSP_RESULT_ERROR; break;`
  - Replace `return MSP_RESULT_ACK;` with `*ret = MSP_RESULT_ACK; break;`
  - Keep the function’s final `return true;` behavior for handled commands.
- Ensure the “not found” path sets `*ret = MSP_RESULT_ERROR` (per docs) and does not accidentally return ACK.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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