JCoder.HCP4Net.LinuxOS 3.2610.1

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

JCoder.HCP4Net.LinuxOS

目录

[TOC]

一.架构说明

JCoder.HCP4Net.LinuxOS
语言 C#
协议 MIT
面向系统 Linux
.Net框架 .Net Standard2.1; .Net Framework 4.7.2; .Net 6; .Net 8; .Net 10;
简述 基于JCoder.HCP4Net的上位机通讯协议客户端类库(面向Linux系统),提供Modbus RTU、Modbus TCP、OPC UA、Siemens S7协议的IHCPClient实现。

1.1 引用类库

引用类库 版本
JCoder.HCP4Net 项目引用

1.2 相关类库

| 相关类库 | 说明 | | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | | JCoder.HCP4Net | 上位机通讯协议的类库(协议适配器与消息定义)。 | | JCoder.HCP4Net.WinOS | 面向Windows系统的上位机通讯协议客户端类库。 |

二.客户端说明

客户端 协议 传输方式 说明
HCPModbusClient Modbus RTU 串口 基于Linux串口设备文件(/dev/ttyS0等)的Modbus RTU客户端。
HCPModbusTcpClient Modbus TCP TCP 默认端口502。
HCPSiemensClient Siemens S7 TCP 默认端口102,连接时自动完成COTP与S7握手。
HCPOpcUaClient OPC UA TCP 默认端口4840,连接时自动完成HEL/ACK握手。

所有客户端均实现IHCPClient接口,支持:

  1. 连接/断开连接(同步与异步);
  2. 请求的发送与响应的接收(同步与异步);
  3. 连接、重连、发送、接收相关事件;
  4. 断线后的自动重连机制(AutoReconnect、ReconnectInterval、ReconnectRetryCount)。

Linux串口权限说明

Linux系统的串口为设备文件(如:/dev/ttyS0、/dev/ttyUSB0),运行程序的用户需要具有读写权限, 可将用户加入 dialout 用户组:

sudo usermod -aG dialout $USER

使用说明

以Modbus RTU为例:

using JCoder.HCP4Net;
using JCoder.HCP4Net.LinuxOS;

var _config = new HCPClientConfigSerial { PortName = "/dev/ttyS0", BaudRate = 9600 };
var _client = new HCPModbusClient(_config);

// 启用自动重连
_client.AutoReconnect = true;
_client.ReconnectInterval = TimeSpan.FromSeconds(3);
_client.ReconnectRetryCount = 5;

// 订阅事件
_client.OnConnected += (sender, config) => { /* 连接成功 */ };
_client.OnReceiveSucceeded += (sender, response) => { /* 接收成功 */ };

if (_client.Connect())
{
    var _request = new HCPModbusRequestMessageForRead { SlaveAddress = 0x01, Address = 0x0000, Content = (ushort)10 };
    var _response = _client.SendRequest<HCPModbusResponseMessage>(_request);
    _client.Disconnect();
}

参考

  1. 参考JCoder.HCP4Net
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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 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 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 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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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

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
3.2612.1 99 9/13/2026
3.2611.1 96 9/11/2026
3.2610.1 102 8/24/2026

Please contact Jackie by QQ 1378071853 or E-mail JackieLaw-dev@outlook.com;