04-22-2020 08:00 AM
Hello, everyone!
I am trying to use the FOCAS2 library DLL to communicate my computer with a CNC machine and I am using the Call Library Function Node for doing this. I am quite new at DLL management, but various topics in this forum were really useful and helped me a lot. The question I am bringing in here is about getting the values from a pointer to a structure. Here is the DLL function I am bringing for a example:
FWLIBAPI short WINAPI cnc_machine(unsigned short FlibHndl, short axis, short length, ODBAXIS *machine);
This function reads the machine position data of axis specified with "axis". The description of the parameters, as can be found in this website (https://www.inventcom.net/fanuc-focas-library/Position/cnc_machine), shows the following:
Pointer to the ODBAXIS structure including the machine position data of the controlled axes. The ODBAXIS structure is as follows.
typedef struct odbaxis { short dummy ; /* Not used. */ short type ; /* Axis number. */ long data[MAX_AXIS] ; /* Machine position data of controlled axis. */ } ODBAXIS ; /* MAX_AXIS is the maximum controlled axes. */
As I saw on this post at the forum (https://forums.ni.com/t5/Developer-Center-Resources/Passing-and-Receiving-Pointers-with-C-C-DLLs-fro... and https://forums.ni.com/t5/Developer-Center-Resources/Dereferencing-Pointers-from-C-C-DLLs-in-LabVIEW/...), I can receive a pointer and automatically dereferencing it, apparently. So can I automatically dereference a structure, as I did on the VI in attachment? Or the way I did will I get the pointers and not the values?
I did not test this at the machine yet. But, because my time working with the machine is limited, it would be nice to get there with some certainty, in order to avoid waste too much time with some noob errors.
Thanks in advance!
Guilherme da Silva
04-22-2020 08:45 AM
It looks correct, do you get any result?