You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
readData populates the int8Array with a collection of header(uint16) and body (basically structures) pairs. The uint32Ptr argument is populated with the total number of bytes written to the passed int8Array.
My problem is that after I call readData, I cannot figure out how to reinterpret pieces of the int8Array as another data type. I'm fairly confident that the readData call is populating the array correctly.
So rather than using int8Array type, just specify "pointer" (or "void *"), and pass in a Buffer instance big enough to hold your data (10000 bytes it looks like from the code you've given).
Then, you'd basically use the built-in Buffer read functions (readUint16LE(), etc.) to read out the values, incrementing the position as you go along. You said that the body is basically a struct, so you might be able to utilize ref-struct here as well.
I cannot seem to figure this one out. I'm sure the answer is simple, I just cannot get it right. Any help would be appreciated.
I'm using ref-array with node-ffi. I have a c library function which has a signature like this:
readData populates the int8Array with a collection of header(uint16) and body (basically structures) pairs. The uint32Ptr argument is populated with the total number of bytes written to the passed int8Array.
My problem is that after I call readData, I cannot figure out how to reinterpret pieces of the int8Array as another data type. I'm fairly confident that the readData call is populating the array correctly.
I need to do something like this:
Is this possible?
The text was updated successfully, but these errors were encountered: