finds.dev← search

// the find

kiltum/modbus

★ 240 · C · NOASSERTION · updated Aug 2022

Very simple modbus for STM32 HAL FreeRTOS

A minimal Modbus RTU slave implementation for STM32 HAL + FreeRTOS, implemented as two files (modbus.c/h) that communicate via CMSIS-RTOS message queues. It handles holding register read/write (function codes 03/06/16) without requiring a dedicated timer — inter-character gap detection is done by timing out on the queue read. Aimed at embedded developers who want a drop-in starting point, not a production library.

Timer-free gap detection is genuinely clever for the constraints — using osMessageGet timeout to detect end-of-frame avoids consuming a hardware timer resource. The two-file drop-in design means integration is a copy-paste, no build system changes needed. The queue-based I/O abstraction actually works for USB-CDC, UART, or anything else that can push bytes into a queue. A complete working example project on STM32F3-Discovery with Keil is included, which is more than most similar repos bother with.

Only implements holding registers (FC03/FC06/FC16) — no coils, discrete inputs, or input registers, so about half of standard Modbus is missing. The register store is a flat array with no locking, meaning concurrent access from application code and the Modbus thread is a data race waiting to bite you. Last commit is 2022 against a version of CMSIS-RTOS v1 (osMessagePut/osMessageGet), which are deprecated in v2 and removed in some toolchain configs. No error response handling — a malformed or unsupported request just gets silently dropped rather than returning the proper exception code.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →