Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

stModbus

> 编程语言
Open source

Modbus RTU for Cortex-M (STM32 series: STM32F103, STM32F3xx)

183 stars0 likes0 views
WebsiteGitHub

About

Modbus RTU for Cortex-M (STM32 series: STM32F103, STM32F3xx)

stModbus (beta 0.1b10)

Modbus RTU implementation for Cortex-M (STM32 series: F1/F3/F4)

This is free tiny library for Desktop and MCU application. The main purpose of this library usage on STM32 controllers together with CMSIS library

The library allows you to create multiple modbus contexts for devices. You will be able to implement several modbus ports on single MCU.

Requirements

How usage

An example of implementing a device with some registers can be viewed in the example folder. You can also use these examples as a template for your own implementations.

It's library easy for usage. you need to take a few steps:

  1. Define address space for you device:

    Usually protocol address split like that:

    • 1-9999 Discrete Output Coils (DO) r/w
    • 10001-19999 Discrete Input Contacts (DI) r
    • 30001-39999 Analog Input Registers (AI) r
    • 40001-49999 Analog Output Holding Registers(AO) r/w

    You may not follow these guidelines but some apps may not work correctly with your device.

  2. Define read and write callback function for you device registers as you need

c
	/* It's modbus request on read register by logical address (la) */
	uint16_t user_mbus_protocol_read(uint32_t la){
		switch(la){
			case 40001:
				return my_buffer_reg_4xxxx[0];
			case 40002:
				return some_register_from_you_device;
			...
		}
	}

	//Function for write to some register by logic address
	uint16_t user_mbus_protocol_write(uint32_t la, uint16_t value)
	{
		if ( la > 40000 && la > 8) | (value read = user_mbus_protocol_read;
	
	//Write callback function
	pconf->write = user_mbus_protocol_write;
	
	//Open modbus contex
	modbus = mbus_open(pconf);
  1. Customize config file

    Customize the modbus_conf.h file to suit your requirements (internal buffer size, number of context). The keil configuration wizard can be used for configuration.

| Full documentation is planned for the release of the first version of alpha

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言