Skip to content

Commit

Permalink
v1.8.2024.0217 部分非标设备Modbus地址从0开始,可能是读取线圈或寄存器,此时Range为空
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Feb 17, 2024
1 parent e671e97 commit 48044f4
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion NewLife.Modbus/Drivers/ModbusDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ internal IDictionary<String, Object> Dispatch(IPoint[] points, IList<Segment> se
var count = GetCount(point);

// 找到片段 需要补充类型过滤参数避免不同类型相同地址取值错误问题
var seg = segments.FirstOrDefault(e => e.Address <= maddr.Address && maddr.Address + count <= e.Address + e.Count && e.ReadCode == maddr.Range.ReadCode);
var seg = segments.FirstOrDefault(e => e.Address <= maddr.Address && maddr.Address + count <= e.Address + e.Count && (maddr.Range == null || e.ReadCode == maddr.Range.ReadCode));
if (seg != null && seg.Data != null)
{
var code = seg.ReadCode;
Expand Down
10 changes: 8 additions & 2 deletions NewLife.Modbus/NewLife.Modbus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,28 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageReadmeFile>Readme.MD</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NewLife.Core" Version="10.6.2024.101" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.IoT" Version="2.0.2024.101" />
<PackageReference Include="NewLife.IoT" Version="2.1.2024.203" />
</ItemGroup>

<ItemGroup>
<Content Include="..\Doc\leaf.png" Link="leaf.png" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<None Include="..\Readme.MD">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

</Project>
8 changes: 7 additions & 1 deletion NewLife.ModbusRTU/NewLife.ModbusRTU.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageReadmeFile>Readme.MD</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NewLife.Core" Version="10.6.2024.101" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net461' or '$(TargetFramework)'=='netstandard2.0' or '$(TargetFramework)'=='netstandard2.1'">
<PackageReference Include="System.IO.Ports" Version="6.0.0" />
Expand All @@ -59,6 +59,12 @@
<ItemGroup>
<Content Include="..\Doc\leaf.png" Link="leaf.png" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<None Include="..\Readme.MD">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NewLife.Modbus\NewLife.Modbus.csproj" />
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="10.6.2024.101" />
<PackageReference Include="NewLife.Core" Version="10.7.2024.202" />
</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="10.6.2024.101" />
<PackageReference Include="NewLife.Core" Version="10.7.2024.202" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions XUnitTest/XUnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="NewLife.Core" Version="10.6.2024.101" />
<PackageReference Include="xunit" Version="2.6.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PackageReference Include="NewLife.Core" Version="10.7.2024.202" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down

0 comments on commit 48044f4

Please sign in to comment.