CSoft.Protocol.Modbus 10.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package CSoft.Protocol.Modbus --version 10.0.0
                    
NuGet\Install-Package CSoft.Protocol.Modbus -Version 10.0.0
                    
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="CSoft.Protocol.Modbus" Version="10.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSoft.Protocol.Modbus" Version="10.0.0" />
                    
Directory.Packages.props
<PackageReference Include="CSoft.Protocol.Modbus" />
                    
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 CSoft.Protocol.Modbus --version 10.0.0
                    
#r "nuget: CSoft.Protocol.Modbus, 10.0.0"
                    
#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 CSoft.Protocol.Modbus@10.0.0
                    
#: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=CSoft.Protocol.Modbus&version=10.0.0
                    
Install as a Cake Addin
#tool nuget:?package=CSoft.Protocol.Modbus&version=10.0.0
                    
Install as a Cake Tool

Modbus协议:

IModBusMaster modBus = new ModBusMaster(new SerialPort("COM2"), ModbusType.TCP);
await modBus.OpenAsync();
var b = new BlockList();
b.Add(new ProtocolData());
//var rs = await modBus.GetAsync("01", b);
var rs = await modBus.GetAsync<ProtocolData>("01", b);

// rs 的类型为 List<ProtocolData>
Console.WriteLine($"A: {rs.A}, B: {rs.B}, C: {rs.C}, D: {rs.D}");

public class ProtocolData
{
    [CHProtocol(1, "a")]
    public float A { get; set; }

    [CHProtocol(3)]
    public UInt16 B { get; set; }

    [CHProtocol(4)]
    public float C { get; set; }

    [CHProtocol(9)]
    public float D { get; set; }
}

下边的都过时了

IModBusMaster modBusRtu = new ModBusMaster(new SerialPort("COM2"));

//01 03 00 01 00 05 D4 09 -> 01 03 0A 41 A0 00 00 00 15 41 B0 00 00 97 B8(20、21、22)
var block = new Modbus.Parameter.BlockInfo();

block.ChannelInfos.Add(new() { ChannelId = "1", RegisterAddress = 1, ValueType = RegisterValueType.Float });
block.ChannelInfos.Add(new() { ChannelId = "2", RegisterAddress = 3, ValueType = RegisterValueType.UInt16 });
block.ChannelInfos.Add(new() { ChannelId = "3", RegisterAddress = 4, ValueType = RegisterValueType.Float });

modBusRtu.BlockInfos.Add(block);

//01 03 00 09 00 06 15 CA -> 01 03 0C 41 F0 00 00 42 20 00 00 42 48 00 00 5C CA(30、40、50)
block = new Modbus.Parameter.BlockInfo();
block.ChannelInfos.Add(new() { RegisterAddress = 9, ValueType = RegisterValueType.Float });
block.ChannelInfos.Add(new() { RegisterAddress = 11, ValueType = RegisterValueType.Float });
block.ChannelInfos.Add(new() { RegisterAddress = 13, ValueType = RegisterValueType.Float });

modBusRtu.BlockInfos.Add(block);

block = new Modbus.Parameter.BlockInfo();
block.AddChannelInfos(15, 300, RegisterValueType.UInt16);
modBusRtu.BlockInfos.Add(block);

await modBusRtu.OpenAsync();

var rs = await modBusRtu.GetAsync("01");

//01 03 11 00 00 0A C0 F1->03 10 14 56 65 72 30 39 30 49 5F 32 34 30 35 32 31 5F 30 39 32 37 5F B2 F3
var b = new Modbus.Parameter.BlockInfo();
b.ChannelInfos.Add(new() { ChannelId = "1", RegisterAddress = 0x1100, ValueType = RegisterValueType.String, Count = 10 });
var rs = await modBusRtu.GetAsync("01", b);
var str = Encoding.ASCII.GetString((byte[])rs[0].Value);

//await modBusRtu.SetAsync("01",
//    [
//    new Modbus.Parameter.SetBlockInfo() { RegisterAddress = 01, Data = [0x3F, 0x80, 0x00, 0x00] },
//    new Modbus.Parameter.SetBlockInfo() { RegisterAddress = 03, Data = [0x3F, 0x80, 0x00, 0x00] }
//    ]);
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 is compatible.  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 is compatible.  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 is compatible.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on CSoft.Protocol.Modbus:

Package Downloads
CSoft.Protocol.TPF146D

泽天温压流146D通讯协议

CSoft.Protocol.DustAnalyzerSampling

泽天抽取粉尘仪通讯协议

CSoft.Protocol.TPF113B

泽天温压流113B通讯协议

CSoft.Protocol.DustAnalyzerSquare

泽天方型粉尘仪通讯协议

CSoft.Protocol.DustAnalyzerCircular

泽天圆型粉尘仪通讯协议

GitHub repositories

This package is not used by any popular GitHub repositories.

更新依赖