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 )

等等。一些函数是不共用的。
三、由于移植繁琐,不过多介绍直接给出工程文件参考就行。
工程文件

猜你喜欢

转载自blog.csdn.net/qq_15181569/article/details/106793008