Modbus is an automation protocol originally specified for serial networks such as RS-485 (Modbus RTU). It has since been adapted for Ethernet networks (Modbus TCP).
M-Bus from RT-Labs is a Modbus stack that implements a Modbus master or device. It supports Modbus RTU and Modbus TCP and can be run on bare-metal hardware, or on an RTOS such as RT-Kernel.
The M-Bus stack is supplied with full sources including a porting layer. The application interfaces with the stack primarily via a set of callbacks to get and set Modbus registers and coils.