From e28ec36addeee8eae304607b49be52dccab1fcea Mon Sep 17 00:00:00 2001 From: timyhac Date: Wed, 9 Oct 2024 19:43:51 +1100 Subject: [PATCH] Fix accidental changes to GetBuffer (#422) Also change SetBuffer back to be a simple wrapper for plc_tag_set_raw_bytes --- src/libplctag/Tag.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/libplctag/Tag.cs b/src/libplctag/Tag.cs index 607d701..e0f4505 100644 --- a/src/libplctag/Tag.cs +++ b/src/libplctag/Tag.cs @@ -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); } @@ -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); }