c#NModbus读取报错

Bulusi.li 2021-12-30 14:18:38
2021-12-30 13:49:26.8848|二厂化镀色泽检测.MachineRunningStatus|ERROR|NModbus.SlaveException: Exception of type 'NModbus.SlaveException' was thrown.
Function Code: 129
Exception Code: 2 - The data address received in the query is not an allowable address for the server (or slave). More specifically, the combination of reference number and transfer length is invalid.For a controller with 100 registers, the PDU addresses the first register as 0, and the last one as 99. If a request is submitted with a starting register address of 96 and a quantity of registers of 4, then this request will successfully operate(address-wise at least) on registers 96, 97, 98, 99. If a request is submitted with a starting register address of 96 and a quantity of registers of 5, then this request will fail with Exception Code 0x02 “Illegal Data Address” since it attempts to operate on registers 96, 97, 98, 99 and 100, and there is no register with address 100.
   at NModbus.IO.ModbusTransport.UnicastMessage[T](IModbusMessage message)
   at NModbus.Device.ModbusMaster.PerformReadDiscretes(ReadCoilsInputsRequest request)
   at NModbus.Device.ModbusMaster.ReadCoils(Byte slaveAddress, UInt16 startAddress, UInt16 numberOfPoints)
   at 二厂化镀色泽检测.MachineRunningStatus.timerCallback(Object state) in F:\测试程序\拍照\MachineRunningStatus.cs:line 135 NModbus.SlaveException: Exception of type 'NModbus.SlaveException' was thrown.

没错啊,配置都是对的。请前辈们帮忙看下! 

 

 

...全文
3225 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Gk_tong 2022-01-05
  • 打赏
  • 举报
回复

从站的返回方法是0X03 读取字
你调用的方法是0x01读取位 两者在内存中对应的地址不一样
你把从站的方法改成0x01就行了

Bulusi.li 2022-01-06
  • 举报
回复
@Gk_tong 是的 我把modbus那邊數據類型改爲布爾型就好了

111,131

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧