How cwalter-at/freemodbus works
FreeModbus is an embedded Modbus application-protocol library supporting ASCII, RTU, and TCP transports. An application initializes and polls the stack; the selected transport receives and validates a frame, the core dispatches its function code, and handlers use application callbacks for register data before a response is sent. The repository also includes multiple platform-specific port implementations under demo/, but the sampled evidence establishes only the generic port interface. Relationships beyond explicit excerpts or indexed references are omitted.
Main entry points: mb.c Stack API and Dispatch · mbrtu.c RTU Framing · mbascii.c ASCII Framing · mbport.h Port API
Components 15
Protocol Core
- Stack API and Dispatch
modbus/mb.c - Protocol Definitions
modbus/include/mbproto.h - Frame Interface
modbus/include/mbframe.h - Feature Configuration
modbus/include/mbconfig.h
Frame Transports
- ASCII Framing
modbus/ascii/mbascii.c - RTU Framing
modbus/rtu/mbrtu.c - RTU CRC
modbus/rtu/mbcrc.c - TCP Framing
modbus/tcp/mbtcp.c
Function Handlers
- Coil Functions
modbus/functions/mbfunccoils.c - Holding Registers
modbus/functions/mbfuncholding.c - File Functions
modbus/functions/mbfuncfile.c - Other Functions
modbus/functions
Port Interface
- Port API
modbus/include/mbport.h
Other components
- Modbus Application
- Register Callbacks
Connections 17
- Modbus Application → Stack API and Dispatch: initializes and polls
- Stack API and Dispatch → ASCII Framing: selects framing
modbus/mb.c - Stack API and Dispatch → RTU Framing: selects framing
modbus/mb.c - Stack API and Dispatch → TCP Framing: selects framing
modbus/mb.c - Stack API and Dispatch → Coil Functions: dispatches function
modbus/mb.c - Stack API and Dispatch → Holding Registers: dispatches function
modbus/mb.c - Stack API and Dispatch → File Functions: dispatches function
modbus/mb.c - Stack API and Dispatch → Other Functions: dispatches function
modbus/mb.c - ASCII Framing → RTU Framing: reuses receive buffer
modbus/ascii/mbascii.c - RTU Framing → RTU CRC: checks frame CRC
modbus/rtu/mbrtu.c - ASCII Framing → Port API: uses port services
modbus/ascii/mbascii.c - RTU Framing → Port API: uses port services
modbus/rtu/mbrtu.c - TCP Framing → Port API: uses TCP services
modbus/tcp/mbtcp.c - Holding Registers → Register Callbacks: reads or writes registers
modbus/functions/mbfuncholding.c - Stack API and Dispatch → Protocol Definitions: uses function codes
modbus/mb.c - Stack API and Dispatch → Frame Interface: uses frame callbacks
modbus/mb.c - Stack API and Dispatch → Feature Configuration: configures enabled features
modbus/mb.c