2 Star 34 Fork 12

XingLucifer / XLModbusTCP

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

XLModbusTCP

介绍

新时代的Modbus TCP通信库

该库的特点

1:某一块内存映射成对象

2:可以读写保持寄存器位

使用说明

声明:private IModbus _modbus;

初始化:_modbus = new ModbusTcp(txtIP.Text, Convert.ToInt32(txtPORT.Text), Convert.ToByte(txtADDR.Text));

打开:_modbus.Open();

关闭:_modbus.Close();

注意事项:该库异常直接抛出,请用户自行捕获

方法大全

保持寄存器方法 写值支持类型:(int uint short ushort float double long ulong)

单写 bool SetRegister(int iaddress, object value);

多写 bool SetRegister(int iaddress, List value) where TValue : struct;

写位(慎用,会覆盖其他位) bool SetBitRegister(int iaddress, int offset, bool value);

写位(建议) bool SetBitRegister(int iaddress, ushort old_value, int offset, bool value);

多位写 bool SetBitsRegister(int iaddress, List value);

多写(建议使用泛型的那个方法) bool SetRegister(int iaddress, ushort[] value);

多读位 List ReadBitsRegister(int iaddress, int count);

单读位 bool ReadBitRegister(int iaddress, int offset = 0);

单读 TValue ReadRegister(int iaddress) where TValue : struct

读多字 List ReadRegister(int iaddress, int count);

读类 T ReadClass(int iaddress) where T : class;

输入寄存器方法

单读 ushort ReadInputRegister(int iaddress);

多读 List ReadInputRegister(int iaddress, int count);

单读位 bool ReadInputBitRegister(int iaddress, int offset = 0);

多读位 List ReadInputBitsRegister(int iaddress, int count);

线圈方法

单线圈写 bool SetCoil(int iaddress, bool value);

多线圈写 bool SetCoil(int iaddress, bool[] value);

读多个线圈 List GetCoil(int iaddress, int count = 0);

读单个线圈 bool GetCoil(int iaddress);

离散寄存器方法

获取多个 List GetDiscreteInput(int iaddress, int count = 0);

获取单个 bool GetDiscreteInput(int iaddress);

MIT License Copyright (c) 2022 XinLucifer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

新时代的Modbus TCP通信库 展开 收起
C#
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C#
1
https://gitee.com/XingLucifer/xlmodbus-tcp.git
git@gitee.com:XingLucifer/xlmodbus-tcp.git
XingLucifer
xlmodbus-tcp
XLModbusTCP
master

搜索帮助