SHModbus 1.0.2

dotnet add package SHModbus --version 1.0.2
                    
NuGet\Install-Package SHModbus -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SHModbus" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SHModbus" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="SHModbus" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SHModbus --version 1.0.2
                    
#r "nuget: SHModbus, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SHModbus@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SHModbus&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=SHModbus&version=1.0.2
                    
Install as a Cake Tool

开始学习上位机

这里就是写了一些工具库 .不知道 能否用的上.

  • using SHModbus.Providers;


//SModbusRTU modbusRTU = new SModbusRTU("COM20", 9600, null, null, null);
//modbusRTU.Connection();


//var btt = modbusRTU.ReadOutputCoil(1, 0, 10);
//Console.WriteLine(btt);
////// 写入单个线圈
//var bt = modbusRTU.WriteOutputCoil(1, 0, true);
//Console.WriteLine(bt);
//// 写入多个线圈
// bt = modbusRTU.WriteMoreOutputCoil(1, 0, 10,new byte[] { 10,1});
//Console.WriteLine(bt);

// 读取输出寄存器
//var btt = modbusRTU.ReadOutputRegisters(1, 0, 2);
//Console.WriteLine(btt);
//// 写入输入寄存器
//var bt = modbusRTU.WriteOutputRegisters(1, 0, 10);
//Console.WriteLine(bt);
//// 写入多个寄存器
// bt = modbusRTU.WriteMoreOutputRegisters(1, 0, new ushort[] { 10, 10, 10 });
//Console.WriteLine(bt);

//// 读取输入线圈
//var btt = modbusRTU.ReadInputCoil(1, 0, 10);
//Console.WriteLine(btt);
//// 读取输出线圈

// 读取输入寄存器
//var btt = modbusRTU.ReadInputRegisters(1, 0, 10);
//Console.WriteLine(btt);



SModbusTCP modbusRTU = new SModbusTCP(IPAddress.Parse("127.0.0.1"), 502);
modbusRTU.Connection();
\
//// 写入多个线圈
//var bt = modbusRTU.WriteMoreOutputCoil(1, 0, 10,new byte[] { 10,1});
//Console.WriteLine(bt);
//// 写入单个线圈
//var bt = modbusRTU.WriteOutputCoil(1, 1,true);
//Console.WriteLine(bt);
//// 写入输入寄存器
//var bt = modbusRTU.WriteOutputRegisters(1, 0, 10);
//Console.WriteLine(bt);
//// 写入多个寄存器
//var bt = modbusRTU.WriteMoreOutputRegisters(1,0, new ushort[] { 10,10,10});
//Console.WriteLine(bt);
//// 读取输出寄存器
//var btt = modbusRTU.ReadOutputRegisters(1, 0, 2); 
//Console.WriteLine(btt);
//// 读取输入线圈
//var btt = modbusRTU.ReadInputCoil(1, 0, 10);
//Console.WriteLine(btt);
//// 读取输出线圈
//var btt = modbusRTU.ReadOutputCoil(1, 0, 10);
//Console.WriteLine(btt);
// 读取输入寄存器
var btt = modbusRTU.ReadInputRegisters(1, 0, 10);
Console.WriteLine(btt);

modbusRTU.DisConnection();

说明: 这里COMI 的是用 信号量来 思想数据读取等待的. 没有处理多线程. Socket 的直接就是 等待读取数据.


<h2> 如果存在问题 告诉我 我会第一时间改正

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 516 10/23/2022
1.0.1 598 10/23/2022 1.0.1 is deprecated because it is no longer maintained.
1.0.0 429 10/22/2022