zhaopeiym / IoTClient

This is an IoT device communication protocol implementation client, which will include common industrial communication protocols such as mainstream PLC communication reading, ModBus protocol, and Bacnet protocol. This component is open source and free for life, using the most relaxed MIT open source agreement, you can modify and commercial use at will (commercial use please evaluate and test). 这是一个物联网设备通讯协议实现客户端,将会包括主流PLC通信读取、ModBus协议、Bacnet协议等常用工业通讯协议。本组件终身开源免费,采用最宽松的MIT开源协议,您可以随意修改和商业使用(商业使用请做好评估和测试)。

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

如何往多个寄存器分开写值

chakloong883 opened this issue · comments

我想用modbustcp在一个地址的连续两个寄存器分开写两个值,请问是如何写入?实例好像都是写一个值

https://github.com/zhaopeiym/IoTClient/blob/master/README-zh_CN.md#modbustcp%E8%AF%BB%E5%86%99%E6%93%8D%E4%BD%9C

//6、批量读取
var list = new List<ModBusInput>();
list.Add(new ModBusInput()
{
    Address = "2",
    DataType = DataTypeEnum.Int16,
    FunctionCode = 3,
    StationNumber = 1
});
list.Add(new ModBusInput()
{
    Address = "2",
    DataType = DataTypeEnum.Int16,
    FunctionCode = 4,
    StationNumber = 1
});

var list = new List();
list.Add(new ModBusInput()
{
Address = "2",
DataType = DataTypeEnum.Int16,
FunctionCode = 3,
StationNumber = 1
});
list.Add(new ModBusInput()
{
Address = "2",
DataType = DataTypeEnum.Int16,
FunctionCode = 4,
StationNumber = 1
})

这个是批量读取,我是想写入数值,功能码是16的话该怎么写?

批量写入暂时没提供。

但是功能码16不是应该可以写入多个寄存器?