How monash-railway-express/can_mrex works
CAN MREX is an embedded CAN/CANopen-style wrapper for MREx locomotive nodes. A node application supplies its node ID and calls the library’s handler; the handler services operational PDO transmission and heartbeat work, receives or accepts a CAN frame, then dispatches it by COB-ID to NMT, EMCY, PDO, SDO, or heartbeat handling. The object dictionary provides shared node state and indexed values. README documents all six protocol capabilities; the available source excerpts establish handler dispatch and several dictionary dependencies, but do not show the public wrapper, configuration, or NMT implementation.
Main entry points: CM_Handler.cpp Frame handler · CM_Heartbeat.cpp Heartbeat monitor · CM_ObjectDictionary.cpp Object dictionary · CM_EMCY.cpp Emergency messages
Components 11
Node Interface
- Library API
src/CAN_MREx.h - CAN configuration
src/CM_Config.cpp
CAN Dispatch
- Frame handler
src/CM_Handler.cpp
CANopen Services
- NMT control
src/CM_NMT.cpp - Emergency messages
src/CM_EMCY.cpp - Process data
src/CM_PDO.cpp - Structured data
src/CM_SDO.cpp - Heartbeat monitor
src/CM_Heartbeat.cpp
Node State
- Object dictionary
src/CM_ObjectDictionary.cpp
Other components
- Node application
- TWAI CAN driver
Connections 15
- Node application → Library API: uses
- Library API → Frame handler: dispatches
- CAN configuration → TWAI CAN driver: configures
- Frame handler → TWAI CAN driver: receives frames
src/CM_Handler.cpp - Frame handler → Process data: services and processes
src/CM_Handler.cpp - Frame handler → Heartbeat monitor: sends and checks
src/CM_Handler.cpp - Frame handler → NMT control: dispatches NMT
src/CM_Handler.cpp - Frame handler → Emergency messages: dispatches EMCY
src/CM_Handler.cpp - Frame handler → Structured data: dispatches SDO
src/CM_Handler.cpp - Frame handler → Heartbeat monitor: dispatches frames
src/CM_Handler.cpp - Emergency messages → Object dictionary: uses entries
src/CM_EMCY.cpp - Process data → Object dictionary: uses entries
src/CM_PDO.cpp - Structured data → Object dictionary: uses entries
src/CM_SDO.cpp - Heartbeat monitor → Object dictionary: uses state
src/CM_Heartbeat.cpp - Heartbeat monitor → Emergency messages: reports faults
src/CM_Heartbeat.cpp