Skip to content

Commit

Permalink
After some comments on #359 it became clear that there was a bug in l…
Browse files Browse the repository at this point in the history
…ibplctag.NET wrapper code.

Previously it was enforcing the result of set_size to be 0, but the core API says that it is only an error on a negative result and a positive result indicates the previous size.
  • Loading branch information
timyhac committed Jun 15, 2024
1 parent 1689dad commit 70581d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/libplctag/NativeTagWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,14 @@ public int GetSize()
return result;
}

public void SetSize(int newSize)
public int SetSize(int newSize)
{
ThrowIfAlreadyDisposed();
var result = (Status)_native.plc_tag_set_size(nativeTagHandle, newSize);
ThrowIfStatusNotOk(result);
var result = _native.plc_tag_set_size(nativeTagHandle, newSize);
if (result < 0)
throw new LibPlcTagException((Status)result);
else
return result;
}

public Status GetStatus()
Expand Down
2 changes: 1 addition & 1 deletion src/libplctag/Tag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public uint? StringTotalLength
/// </summary>
public byte[] GetByteArrayAttribute(string attributeName) => _tag.GetByteArrayAttribute(attributeName);
public int GetSize() => _tag.GetSize();
public void SetSize(int newSize) => _tag.SetSize(newSize);
public int SetSize(int newSize) => _tag.SetSize(newSize);

/// <summary>
/// Check the operational status of the tag
Expand Down

0 comments on commit 70581d4

Please sign in to comment.