Modbus写单线圈代码C# [英] Modbus write single coil code C#

查看:428
本文介绍了Modbus写单线圈代码C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有c#代码写一个线圈(RTU Modbus)?



我试过的:



试图在谷歌搜索代码,但没有找到任何东西

does anyone has a code for c# for writing a single coil (RTU Modbus)?

What I have tried:

tried to search on google for the code but didnt find anything

推荐答案

您可以编写自己的代码。这并不困难。从学习开始: MODBUS规范 [ ^ ]。

假设您要将1写入地址250处的线圈。然后您必须在串行线上发送以下内容请求(假设lave地址为1):

You might write your own code. It is not difficult. Start by studying : the MODBUS specifications[^].
Suppose you want to write 1 to the coil at address 250. Then you have to send on the serial line the following request (assuming the lave address is 1):
slv  fun   address    data    checksum
0x01 0x05 0x00 0xFA 0xFF 0x00 0x0B 0xAC



唯一棘手的部分是校验和计算。但是,只需谷歌搜索就可以找到可用的代码。


The only tricky part is the checksum computation. However, just Googling you could find available code for that.


这篇关于Modbus写单线圈代码C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆