Skip to content

Commit

Permalink
升级net9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Dec 3, 2024
1 parent 7efa2c6 commit db14338
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 27 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/publish-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
- uses: actions/checkout@v4
- name: Setup dotNET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.x
- name: Restore
run: |
dotnet restore NewLife.Modbus/NewLife.Modbus.csproj
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
- uses: actions/checkout@v4
- name: Setup dotNET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.x
- name: Restore
run: |
dotnet restore NewLife.Modbus/NewLife.Modbus.csproj
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
- uses: actions/checkout@v4
- name: Setup dotNET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.x
- name: Build
run: dotnet build -c Release

Expand Down
2 changes: 1 addition & 1 deletion NewLife.Modbus/Drivers/ModbusDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public override IDictionary<String, Object> Read(INode node, IPoint[] points)
// 其中一项读取报错时,直接跳过,不要影响其它批次
try
{
seg.Data = Modbus.Read(seg.ReadCode, n.Host, (UInt16)seg.Address, (UInt16)seg.Count)?.ReadBytes(-1);
seg.Data = Modbus.Read(seg.ReadCode, n.Host, (UInt16)seg.Address, (UInt16)seg.Count)?.ReadBytes();

//var x = seg.Data.Join(" ", e => e.ToHex());
}
Expand Down
4 changes: 3 additions & 1 deletion NewLife.Modbus/NewLife.Modbus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<LangVersion>latest</LangVersion>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\Doc\newlife.snk</AssemblyOriginatorKeyFile>
<AnalysisLevel>latest</AnalysisLevel>
<WarningsAsErrors>CA2007</WarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -45,7 +47,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.IoT" Version="2.3.2024.1106" />
<PackageReference Include="NewLife.IoT" Version="2.3.2024.1203" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions NewLife.Modbus/Protocols/ModbusIp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ public override void Open()

/// <summary>接收响应</summary>
/// <returns></returns>
protected virtual IPacket ReceiveCommand()
protected virtual IOwnerPacket ReceiveCommand()
{
// 设置协议最短长度,避免读取指令不完整。由于请求响应机制,不存在粘包返回。
var dataLength = 8; // 2+2+2+1+1
IPacket pk = null;
IOwnerPacket pk = null;
for (var i = 0; i < 8; i++)
{
// 阻塞读取
Expand Down Expand Up @@ -137,7 +137,7 @@ internal protected override ModbusMessage SendCommand(ModbusMessage message)
while (true)
{
// 设置协议最短长度,避免读取指令不完整。由于请求响应机制,不存在粘包返回。
var pk = ReceiveCommand();
using var pk = ReceiveCommand();

if (span != null) span.Tag += Environment.NewLine + pk.ToHex(64, "-");

Expand Down
4 changes: 2 additions & 2 deletions NewLife.Modbus/Protocols/ModbusRtuOverTcp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public class ModbusRtuOverTcp : ModbusIp

/// <summary>接收响应</summary>
/// <returns></returns>
protected override IPacket ReceiveCommand()
protected override IOwnerPacket ReceiveCommand()
{
// 设置协议最短长度,避免读取指令不完整。由于请求响应机制,不存在粘包返回。
var dataLength = 4; // 1+1+2
IPacket pk = null;
IOwnerPacket pk = null;
for (var i = 0; i < 3; i++)
{
// 阻塞读取
Expand Down
4 changes: 2 additions & 2 deletions NewLife.Modbus/Protocols/ModbusRtuOverUdp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public class ModbusRtuOverUdp : ModbusIp

/// <summary>接收响应</summary>
/// <returns></returns>
protected override IPacket ReceiveCommand()
protected override IOwnerPacket ReceiveCommand()
{
// 设置协议最短长度,避免读取指令不完整。由于请求响应机制,不存在粘包返回。
var dataLength = 4; // 1+1+2
IPacket pk = null;
IOwnerPacket pk = null;
for (var i = 0; i < 3; i++)
{
// 阻塞读取
Expand Down
7 changes: 6 additions & 1 deletion NewLife.ModbusRTU/NewLife.ModbusRTU.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.1;netstandard2.0;net45;net461;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.1;netstandard2.0;net45;net461;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<RootNamespace>NewLife.Serial</RootNamespace>
<AssemblyTitle>ModbusRTU协议</AssemblyTitle>
<Description>串口ModbusRTU协议</Description>
Expand All @@ -18,6 +18,8 @@
<LangVersion>latest</LangVersion>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\Doc\newlife.snk</AssemblyOriginatorKeyFile>
<AnalysisLevel>latest</AnalysisLevel>
<WarningsAsErrors>CA2007</WarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -55,6 +57,9 @@
<ItemGroup Condition="'$(TargetFramework)'=='net8.0'">
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net9.0'">
<PackageReference Include="System.IO.Ports" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
<Content Include="..\Doc\leaf.png" Link="leaf.png" PackagePath="\" />
Expand Down
2 changes: 1 addition & 1 deletion Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="11.0.2024.1101" />
<PackageReference Include="NewLife.Core" Version="11.0.2024.1201" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion WinModbus/WinModbus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="11.0.2024.1101" />
<PackageReference Include="NewLife.Core" Version="11.0.2024.1201" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions XUnitTest/XUnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="NewLife.Core" Version="11.0.2024.1101" />
<PackageReference Include="NewLife.Core" Version="11.0.2024.1201" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit db14338

Please sign in to comment.