01-10-2020 11:20 AM - edited 01-10-2020 11:28 AM
Hi,
I am trying to read the magnetic field from a gaussmeter and I came across a problem with 'call library function node'. A sample vi is downloaded from the website and it is showing an error for bad wiring. According to the manual we need to send 4 arguments to the node like : IDN no, COMMAND, pointer to ResponseString variable, string length). Pls have a look at the attached vi. I have no idea how pointer to ResponseString variable works. Pls help. the attached vi should run on 32 bit labview as the dll files are of that bit
01-10-2020 02:12 PM - edited 01-10-2020 02:22 PM
Without the Programmer Manual for your DLL we don't have any idea either!
But one problem you have for sure is that you do not allocate memory space for the result string variable. Without that you pass in a pointer to a buffer of 1 zero byte but tell it that there is a buffer of 80 characters. The DLL happily goes and writes up to 79 characters into the buffer that does not exist => Instant crash or other nastyness!
First you do want to create a subVI for the scpiCommand() function. You don't want to do all the following every time you need to send a command to your instrument!
There are two possibilities:
1) In the Call Library Node for the RESULT parameter configure the Minimum Size to be LENGTH. LabVIEW now will make sure to allocate a buffer of LENGTH character bytes and pass this to the DLL function. On return it scans the string for the NULL termination character and returns the string up to this character back.
2) Place an Initialize Array node on the diagram. Wire an unsigned 8 bit integer constant to the type. Wire your Length variable to the size input. The resulting Byte Array can then be converted into a string with the Byte Array To String node and passed to the Call Library Node.
01-18-2020 05:28 AM
Thank you very much for your reply.