02-04-2019 02:17 PM
Hi,
I'm developing code to interface with a pci platform via LabVIEW on a RHEL 7.4 machine. I was successfully able to create the.so library file and I'm in the process of writing VIs to control the device using my .so and the call library function node. The part I'm hung up on is the pci_access struct contained in the pci.h include file. The struct contains function pointers, and I'm not sure how to mimic these function pointers in a cluster. So my question is two-fold:
1. How do I include function pointers in my cluster?
2. If including function pointers in a cluster is not feasible, how would I go about creating a wrapper function for LabVIEW to handle this struct?
I have attached a file that contains the pci_access struct. Also, I'm doing this development using LabVIEW 2017.
Thanks!
Jason
02-05-2019 03:40 AM
This has been asked (and answered) before:
https://www.google.com/search?q=pointers+in+struct+labview&ie=&oe=
02-05-2019 06:04 AM - edited 02-05-2019 06:11 AM
Thanks for your reply! I’ve seen that solution before, but it doesn’t address my key question. I’m looking to represent a function pointer, not just a pointer to a common data type. As an example, in the struct that I’m referencing, there’s an element “void (*warning)(char *msg,...) PCI_PRINTF(1,2)”, which is a pointer to a function. How do I represent this in a cluster? From what I can gather, you need your cluster elements to match up exactly with your struct elements using the appropriate data type, but I’m not sure how to do that when you are dealing with a pointer to a function. Are you suggesting that I treat it like any other pointer?
02-05-2019 06:26 AM - edited 02-05-2019 06:28 AM
Ah ok.
A function pointer can only (practically) be obtained from a dll. so, build a dll with the function, then use LoadLibraryA (or FindResource) and GetProcAddressA to get a pointer to a function.
That function pointer needs to be a system sized pointer, that you can bundle\cluster and send to a function.
02-06-2019 06:10 PM
Ok, I haven’t tried the solution yet, but I didn’t want to leave you hanging without giving an update. Your solution is for a windows dll, but I’m hoping that it will be the same with a Linux “.so” shared library. Currently I’m verifying I have the correct packages on my Linux computer since I ran into some errors while using the “Call Library Node” that seems to point in the direction of a missing header file. I’ll let you know if your approach works by tomorrow I hope.
02-18-2019 03:44 PM
Sorry for the long delay, had to handle to some family emergencies that cropped up. So I didn’t truly get to implement your solution because the pci.h structs actual have other parameters that I realize would be difficult to implement in labview. I’ve decided to run with wrapper functions that bypass the need for labview to replicate the actual structs. I’ve finished writing the wrapper functions, I just need to test it all out in labview at this point.
Thanks a lot for your help in this. Replicating the pci.h structures turned out to be more challenging then I originally thought.