STM32F103移植FreeModbus實現ModbusRTU和ModbusTCP同時工作

移植過程比較繁瑣就不細說了,說一下注意點就行
一、共用函數
不管是TCP還是RTU有些函數是共用的,比如:

eMBErrorCode eMBRegHoldingCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs, eMBRegisterMode eMode )
eMBErrorCode eMBRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNCoils, eMBRegisterMode eMode )
eMBErrorCodee MBRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNCoils, eMBRegisterMode eMode )
eMBErrorCode eMBRegDiscreteCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNDiscrete )

這幾個函數。
二、不共用函數
TCP和RTU有些函數是不共用的,比如:

eMBErrorCode eMBInit( eMBMode eMode, UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate,eMBParity eParity )
eMBErrorCode eMBTCPInit( USHORT ucTCPPort )
eMBErrorCode eMBEnable( void )
eMBErrorCode eMBTcpEnable( void )

等等。一些函數是不共用的。
三、由於移植繁瑣,不過多介紹直接給出工程文件參考就行。
工程文件

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章