摘要:介紹了以freeMODBUS協議找在嵌入式搶占實時操作系統μC/OS-l的STM32平臺上,成功實現了Modbus協議的移植。通過詳細分析freeMODBUS協議花并編寫STM32F103VET6微處理器的底層驅動,成功實現了工業(yè)Modbus協議RTU和ASCll兩種模式的通信功能。測試結果表明,在實際工業(yè)生產控制和儀表開發(fā)中,應用freeMODBUS協議,完全符合工業(yè)數據采集、實時控制和數據處理等廠級重復性和精確度要求,在一定程度上降低了工業(yè)儀表開發(fā)的周期及成本。關鍵詞:實時操作系統,uC/OS-ll,freeMODBUS,Modbus協議,STM32Abstract:This paper introduces freeMODBUS stack transplanted to the STM32 platform which has been embedded in the preemptive real-time operating system uC/OS-ll,in order that the transplantation of the Modbus protocol is successfuly im-plemented.The freeMODBUS stack is analyzed in detail and STM32F103VET6 microprocessor underlying driver is writed,so that the two Modbus industrial communication function RTU and ASCll are successfully realized.Keywords:time operating system,uC/OS-ll,.freeMODBUS,Modbus協議,STM32
If register should be written or read.This value is passed to the calback functions which support either reading or writing register values. Writing means that the application registers should be updated and reading means that the modbus protocol stack needs to know the current register values.See also: eMBRegHoldingCB(), eMBRegCoilsCB(), eMBRegDiscreteCB() and eMBReglnputCB().Enumeration values: MB_REG_READ Read register values and pass to protocol stack.MB_REG_WRITE Update register values.Note: Note all ports implement this function.A port which wants to get an callback must define the macro MB_PORT_HAS_CLOSE to 1.Returns: If the resources where released it return eMBErrorCode:: MB_ENOERR. If the protocol stack is not in the disabled state it returns eMBErrorCode:: MB_EILLSTATE.Examples: LINUX/demo.c, MCF5235TCP/demo.c, STR71XTCP/demo.c, WIN32/demo. cpp, and WIN32TCP/demo. cpp.his function disables processing of Modbus frames.Returns: If the protocol stack has been disabled