Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetBuffer(byte[] buffer) Not working #421

Closed
dnmalenke opened this issue Oct 9, 2024 · 3 comments
Closed

GetBuffer(byte[] buffer) Not working #421

dnmalenke opened this issue Oct 9, 2024 · 3 comments

Comments

@dnmalenke
Copy link

Seems like the function here:

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);
ThrowIfStatusNotOk(result);
}

does not fill the provided buffer.
It just reads the bytes into a temp buffer.

Line 914 can be updated to:

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

Maybe add a check to prevent reading more than the tag's size if a buffer larger than the tag is passed in?

@kyle-github
Copy link
Member

The underlying core DLL will not copy more data than is in the tag's internal buffer.

@timyhac
Copy link
Collaborator

timyhac commented Oct 9, 2024 via email

@timyhac
Copy link
Collaborator

timyhac commented Oct 9, 2024

@dnmalenke - should be fixed with in main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants