|
楼主 |
发表于 2013-8-16 18:04:50
|
显示全部楼层
//2013/08/16
线圈BUG解决(后来发现不一定是BUG)
1、eMBException eMBFuncWriteCoil( UCHAR * pucFrame, USHORT * usLen )中的
usRegAddress++;行注释掉,否则输出线圈0永远无法输出,其它的线圈错位。
2、eMBException eMBFuncWriteCoil( UCHAR * pucFrame, USHORT * usLen )中的写操作
while循环改加入 usBitOffset += 8; 否则8以后的线圈无法进行写操作。
while( iNCoils > 0 ){
xMBUtilSetBits( ucRegCoilsBuf, usBitOffset,
( uint8_t )( iNCoils > 8 ? 8 : iNCoils ),
*pucRegBuffer++ );
iNCoils -= 8;
usBitOffset += 8;
}
3、细读后发现,usRegAddress++在每个操作下都有,有可能是原版就是有意这么写的,但这样
有违背MODBU协议,也有就是地址0的所有东西是没法操作到的,修改的版本中已可以操作0址
址。
4、合并User.c和rtu.c
|
|