-
Notifications
You must be signed in to change notification settings - Fork 14
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
Sending/Receiving Raw Byte Array #72
Comments
Hi @tonyRyo Yes, it is possible to share and transact "arrays" of data with the UDP Custom Device to and from a model. However, it is not quite done in the way you have displayed here. The UDP Custom Device has another type of packet that can be used - a Buffered packet. A buffered packet exposes a pointer to a preallocated block of memory, which can then be written/read by a model. The model handles packing and unpacking data with the pointer shared by the UDP Custom Device. The Buffered Packet further provides several different mechanisms for pushing the buffered data out on UDP. There is a good bit of documentation provided with the UDP Custom Device help files that goes over the configuration and usage of Buffered packets. I would recommend reviewing those docs and seeing how the Buffered packets fit your use-case. |
Do you happen to have an example of a labview model accessing this buffer? |
Specifically, I'm not using an external buffer. Just the one instantiated by the custom device. I've created a model with inputs for the "Buffer", "Buffer Size", "New Data", "Bytes Received" and "Port". I have them all as doubles. I understand that the "Buffer" input is a pointer, but I'm not sure what to call in LabVIEW to access the data. Thanks. |
Hi @Holtee I don't have a model readily available, but there are portions of this custom device that demonstrate how to access the buffer. I would recommend looking at the code contained in the "Buffered Receive" and the "Buffered Transmit" directories. Of particular note, the way you handle the pointer reference will depend on how you encode it into the double channel. This is where the options between "Conversion Encoding" and "Direct Encoding" will matter. Handling of these is also demonstrated in these directories. I recommend using this toolkit to handle the memory references in LabVIEW: https://github.com/ni/labview-memory-management-tools This toolkit provides a means for creating/reading/writing pointers in LabVIEW. It wraps around (I believe) the DSNewPtr and other native memory management functions in LabVIEW. I'll check in with some of my coworkers to see if they have any models around that are useful for demonstrating pointer access though. I hope what I've put here helps! |
@Holtee I don't have anything immediately to hand, but I should have a model we can share next week to demonstrate this. |
Ryan an TQIgnition, Thanks for the quick responses! I'm going pursue Ryan's suggestion and and a look at the code and see if I can figure it out. Thanks again! |
I messed around with this today and for some reason I'm causing the target to crash. I will wait for the example from TQIgnition. Thanks for your help with this. |
Hi @Holtee, here's a project and a couple of built models (compiled for PharLap in LabVIEW 2020) that demonstrate how to read from a pointer provided by a custom device. One of these uses the library Ryan mentioned above, and the other directly uses the MoveBlock LabVIEW call. Re: crashing the target, this can happen if you attempt to read a NULL pointer. (e.g. if the model tries to read before the custom device provides a valid pointer, for example.) The way this model handles it is by having an explicit ENABLE inport, as well as a check for a zero value on the pointer inport. |
Thanks for the quick response. I will take a look and let you know how it goes. |
Ryan an TQIgnition, I finally got around to testing your example and it works great! Thank you for your help with this. |
Hello,
I wonder if UDP custom device can receive and send the raw byte-array? The size is about 500-900 byte,
I have a model with byte-array (vector) input to decode the UDP Rx raw byte-stream and also output to UDP Tx with byte-array(vector), I want to use UDP custom device to receive and send the data as raw byte array.
It seems that there is only U8 data type in UDP custom device. I am not sure if the setting as below is correct or not.
For Rx
For Tx
Many thanks!
The text was updated successfully, but these errors were encountered: