06-14-2019 10:57 AM
I have been trying to develop a VI that calls the library function that returns a struct with a linked list.The structure looks something like this
typedef struct CSI_Tree
{
/** information of the item. */
CSI_SubItem item;
/** linked list of all items in this hierarchy layer */
struct CSI_Tree *sibling;
/** reference to a sub-tree with all children of the node */
struct CSI_Tree *child;
/** This member indicates whether an attempt has been made to probe for children of this node. Obviously, if
* the member @p child is non-NULL then an attempt has been made to probe for children; but if @p child is NULL
* it is not immediately obvious whether an attempt has occurred. */
int childrenProbed;
} CSI_Tree;
My question is ,is labview capable of retrieving a linked list from a dll or I am just chasing wind?
06-14-2019 11:33 AM
@alpony01 wrote:My question is ,is labview capable of retrieving a linked list from a dll or I am just chasing wind?
Both. LV is capable of doing this, but you are going to crash LV many, many times figuring it out, and probably a few more times after you have figured it out. The resulting code is likely to be very fragile.
I would create a C/C++ wrapper for the DLL and expose a nice, clean interface for LV and perform all indirection inside the C code.
06-17-2019 02:54 AM
Ok.Thank you
06-17-2019 03:37 AM
@alpony01 wrote:My question is ,is labview capable of retrieving a linked list from a dll or I am just chasing wind?
Of course LabVIEW can retrieve a linked list from a dll.
The problem is that the linked list is fragmented in memory. This is kind of the purpose of the linked listed, compared to for instance an array.
You have options:
Flatten the linked list in C(++), for instance by returning the data, and indices in the data array in stead of pointers. That would give LabVIEW just a block of data, that is easy to manage.
Or return the data to the first object, and pointers (or indices) to the previous\next\child\etc objects. Then make LabVIEW walk the linked list... You won't be retrieving the linked list as one, but by traversing the elements, you can duplicate it in LabVIEW by iterating.
Both algorithms will be mostly the same, one does it in the dll, the other in LabVIEW. The first will add complexity to the dll, but LabVIEW will still require complexity to parse the results... But the dll interface will be simple.