原创 介绍FreeMODBUS

2007-8-27 22:46 6865 6 8 分类: MCU/ 嵌入式

介绍一个Modbus协议的实现


中英文介绍一下FreeMODUS。


About


关于


FreeMODBUS是一个针对嵌入式应用的一个免费(自由)的通用MODBUS协议的实现(移植)。Modbus是一个工业制造环境中应用的一个通用协议。一个Modbus通信协议栈包括两层:Modbus应用层协议,该层定义了数据模式和功能;另外一层是网络层。在当前版本中,FreeMODBUS 提供了一个针对Modbus 应用层协议V1.1以及支持在Modbus over serial line speifications 1.0 协议中定义的RTU/ASCII 传输模式。自从0.7版本以后,FreeModbus也支持在 Modbus Messaging on TCP/IP Implementation Guide V1.0a中定义的Modbus TCP协议。FreeModbus是遵循BSD许可证,这意味着用户可以将FreeModbus应用于商业环境中。目前支持的Modbus功能包括:

FreeMODBUS is a free implementation of the popular Modbus protocol specially targeted for embedded systems. Modbus is a popular network protocol in the industrial manufacturing environment. A Modbus communication stack requires two layers. The Modbus Application Protocol which defines the data model and functions and a Network layer. In its current version FreeMODBUS provides an implementation of the Modbus Application Protocol v1.1a and supports RTU/ASCII transmission modes defined in the Modbus over serial line specification 1.0. Since version 0.7 FreeModbus also supports Modbus TCP defined in Modbus Messaging on TCP/IP Implementation Guide v1.0a. It is licensed under the BSD[1] which permits its usage in commercial environments. The following Modbus functions are currently supported:

  • Read Input Register (0x04)
  • Read Holding Registers (0x03)
  • Write Single Register (0x06)
  • Write Multiple Registers (0x10)
  • Read/Write Multiple Registers (0x17)
  • Read Coils (0x01)
  • Write Single Coil (0x05)
  • Write Multiple Coils (0x0F)
  • Read Discrete Inputs (0x02)
  • Report Slave ID (0x11)

  • 读输入寄存器(0x04)
  • 读保持寄存器(0x03)
  • 写单个寄存器 (0x06)
  • 写多个寄存器 (0x10)
  • 读/写多个寄存器(0x17)
  • 读线圈状态 (0x01)
  • 写单个线圈(0x05)
  • 写多个线圈(0x0F)
  • 读离散输入(0x02)
  • 报告从结点ID (0x11)

The implementation is based upon the most recent standards and should be fully standard compliant. Receiving and transmitting of Modbus RTU/ASCII frames is implemented as a state machines which is driven by callbacks from the hardware abstraction layer. This makes porting to new platforms easy. If a frame is complete it is passed to the Modbus Application Layer where its content is inspected. Hooks are available in the Application Layer to add new Modbus functions.


本移植是基于最新的标准并且力求遵循标准。Modbus RTU/ASCII帧的接受和发送通过硬件提取层的回调函数驱动的一个状态机实现的。这就使得该协议很容易移植到新的平台上。当一个数据帧组合完毕,该数据将自动被传到Modbus应用层,数据帧的内容在该应用层得到解释。应用层提供Hooks(钩子函数),以方便增加新的Modbus功能。



If Modbus TCP is used the porting layer must send an event to the protocol stack if a new frame is ready for processing. The protocol stack then calls a function which returns the received Modbus TCP frame and processes it. If valid a response is created and the porting layer is supplied with the Modbus response. It should then send the response back to the client.


如果在处理一个新的数据帧时用到了Modbus TCP,移植层必须向协议层发送一个事件标志。协议层将调用一个返回接收到的Modbus TCP帧的功能函数。如果创建了一个有效的回复并且移植层支持Modbus回复。该层将向子端回复一个反馈。

PARTNER CONTENT

文章评论2条评论)

登录后参与讨论

用户1637240 2014-4-21 06:50

挺好😄

Cybershu 2008-7-10 18:36

继续啊
相关推荐阅读
用户1008175 2010-10-19 16:53
差不多一年没有写日志了,再重新拾起来吧
去年9月份到现在都没写过,期间也很少登陆,都不像个做技术的人了。...
用户1008175 2009-09-22 16:22
PCF8563使用不当产生的问题
PCF8563具有中断输出的功能,当设置的定时器减为0的时候,int管脚电平拉低。在一个应用中,我将int管脚连接到MSP430F1611的一个引脚中断上,期望int管脚不断地产生中断。运行起来后发现...
用户1008175 2009-08-25 09:54
74HC04使用不当导致XTR111电压输出产生问题
74HC04应用不当导致XTR111电压输出问题<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office"...
用户1008175 2009-06-17 15:18
4~20mA电流输出(电流环)应用笔记
最近查了一些4~20mA输出的电路。结合自己的实践做了一下总结。大部分内容来自网上(链接见参考部分)。感兴趣的可以下载看看。...
用户1008175 2009-06-11 09:47
ATmega168的SPI发送完寄存器SPIF不置位的问题
利用ATmega168的硬件SPI驱动74HC595来扩展串行接口。把MOSI和SCK设置为输出,然后设置好寄存器。,具体如下:static void vSpi595Init(void){  DDRB...
用户1008175 2009-02-20 23:46
小问题大智慧
1,100/101跟101/102相比,哪个数大?     能快速回答上来吗?口算比较难了,但是,可以根据特点做个大胆推断,分子比分母小1,是不是相当于比较1/2和2/3谁大哪?显然是后者大。我们再用...
我要评论
2
6
关闭 站长推荐上一条 /3 下一条