Skip to content

Commit

Permalink
Fix accidental changes to GetBuffer (#422)
Browse files Browse the repository at this point in the history
Also change SetBuffer back to be a simple wrapper for plc_tag_set_raw_bytes
  • Loading branch information
timyhac authored Oct 9, 2024
1 parent 149b062 commit e28ec36
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/libplctag/Tag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -926,11 +926,7 @@ public void GetBuffer(byte[] buffer)
public void GetBuffer(int offset, byte[] buffer, int length)
{
ThrowIfAlreadyDisposed();

var tagSize = GetSize();
var temp = new byte[tagSize];

var result = (Status)_native.plc_tag_get_raw_bytes(nativeTagHandle, offset, temp, length);
var result = (Status)_native.plc_tag_get_raw_bytes(nativeTagHandle, offset, buffer, length);
ThrowIfStatusNotOk(result);
}

Expand All @@ -939,12 +935,10 @@ public void SetBuffer(byte[] buffer)
SetBuffer(0, buffer, buffer.Length);
}

public void SetBuffer(int offset, byte[] buffer, int length)
public void SetBuffer(int start_offset, byte[] buffer, int length)
{
ThrowIfAlreadyDisposed();

GetNativeValueAndThrowOnNegativeResult(_native.plc_tag_set_size, buffer.Length);
var result = (Status)_native.plc_tag_set_raw_bytes(nativeTagHandle, 0, buffer, buffer.Length);
var result = (Status)_native.plc_tag_set_raw_bytes(nativeTagHandle, start_offset, buffer, length);
ThrowIfStatusNotOk(result);
}

Expand Down

0 comments on commit e28ec36

Please sign in to comment.