Hanson.Modbus.Slave.Service 2.0.0

dotnet add package Hanson.Modbus.Slave.Service --version 2.0.0                
NuGet\Install-Package Hanson.Modbus.Slave.Service -Version 2.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="Hanson.Modbus.Slave.Service" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Hanson.Modbus.Slave.Service --version 2.0.0                
#r "nuget: Hanson.Modbus.Slave.Service, 2.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.
// Install Hanson.Modbus.Slave.Service as a Cake Addin
#addin nuget:?package=Hanson.Modbus.Slave.Service&version=2.0.0

// Install Hanson.Modbus.Slave.Service as a Cake Tool
#tool nuget:?package=Hanson.Modbus.Slave.Service&version=2.0.0                

README

Hanson.Modbus.Slave.Service

功能說明

簡化 Modbus 相關設備資料讀取及寫入作業

主要功能

  1. 支援 Scan 方式掃描可用的 slave id
  2. 支援讀取功能
    • ReadCoils (0x01)
    • ReadDiscreteInputs(0x02)
    • ReadRegisters(0x03)
    • ReadInputRegisters (0x04)
  3. 支援寫入功能
    • WriteCoil(0x05)
    • WriteRegister(0x06)
    • WriteCoils(0x15)
    • WriteRegisters(0x16)

安裝方式

使用範例

  • RTU & ASCII 使用範例
// 使用 SimpleFactory 建立 RTU 實體 (依實際需求指定不同實體產生的函式)
string comport = "COM1";
byte slaveId = 1;
ushort address = 0;
ushort dataReadLength = 16;
SerialPort serial = new SerialPort(comport);

using (var client = SimpleFactory.CreateModbusRtuClient(serial))
{
	client.Open();

	//讀取方式 
	var readBytes = client.ReadRegisters(slaveId,address,dataReadLength);

	// 寫入方式
	ushort[] values = new ushort[]{0,1,2,3,4,5,6,7};
	var writeBytes = client.WriteRegisters(slaveId,address,values);
    
}
  • TCP & RTU over TCP & ASCII over TCP 使用範例
string ip = "127.0.0.1";
int port = 502;
byte slaveId = 1;
ushort address = 0;
ushort dataReadLength = 16;

using (var client = SmipleFactory.CreateModbusRtuOverTcpClient(ip, port))
{
	client.Open();
    
    //讀取方式 
    var readBytes = client.ReadRegisters(slaveId, address, dataReadLength);

    // 寫入方式
	ushort[] values = new ushort[]{0,1,2,3,4,5,6,7};
	var writeBytes = client.WriteRegisters(slaveId,address,values);
                    
}
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. 
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
2.0.0 194 7/24/2023