Skip to content

Commit

Permalink
修改不同类型点位相同偏移量的场景下连续点位读取的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xi3892 committed Nov 26, 2023
1 parent 7c3b61b commit 768ce62
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions NewLife.Modbus/Drivers/ModbusDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ 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();

var x = seg.Data.Join(" ", e => e.ToHex());
}
catch (Exception ex)
{
Expand Down Expand Up @@ -242,8 +244,8 @@ 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);
// 找到片段 需要补充类型过滤参数避免不同类型相同地址取值错误问题
var seg = segments.FirstOrDefault(e => e.Address <= maddr.Address && maddr.Address + count <= e.Address + e.Count && e.ReadCode == maddr.Range.ReadCode);
if (seg != null && seg.Data != null)
{
var code = seg.ReadCode;
Expand Down

0 comments on commit 768ce62

Please sign in to comment.