LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Need to terminate an array in FindLstn function.

This is the third time I am asking this same question. There are two c programs attached and the two errors which occur identically for both programs. It is simple for someone with a GPIB card in their system. Insert the code into a project. Open the code. Configure an fp as follows: Library/GPIB488.2/GPIB488.2 Functions/System Control/Find All Listeners. Now you are prepared to configure the panel. Address List is "addr_list". Listeners List is "inst_list". FindLstn_3 error occurs when one enters the variables into the panel and FindLstn_4 error occurs when one attempts to run the panel. Please try it and let me know how to terminate the array, addr_list. Thank you.
Download All
0 Kudos
Message 1 of 2
(3,049 Views)
Actually, everybody that has replied to your posts has correctly answered the explicit question that you asked: "How do I terminate the address list passed to the FindLstn function?" But what we didn't realize is that you were trying to execute this improperly inside of a function panel only. Even the code that you posted with this reply leads one to believe that you were receiving a library error when debugging your program's source file. But what is actually happening is that even though you have initialized the array passed to the FindLstn function in your program's source, this code is unknown to the interactive execution of the function's fp.

I have ran the following code on my system flawlessly and it should do the same on yours, notice that it is almost identical to the code in your second attachment although I changed the last parameter to FindLstn to 30 instead of 31 (the Limit parameter is the maximum number of addresses that can fit in the array in addition to the list terminator, -1).

#include
#include

static short addr_list[31];
static short inst_list[31];

int main (int argc, char *argv[])
{
int j;

if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */

SendIFC (0);

addr_list[0] = 0;
for (j = 1; j < 31; j++)
{
addr_list[j] = j;
}
addr_list[30] = -1;

FindLstn (0, addr_list, inst_list, 30);

return 0;
}

Now, as far as "running" the FindLstn function panel goes, as stated in the documentation of the LabWindows/CVI User Manual Chapters 5&6, any variable declarations and assignments needed to properly execute a function panel must be included correctly in the Interactive Execution Window. The reason that you were getting the specific error that you got was because the interactive execution of the FindLstn function was passed an array without -1 assigned to its last index. So, in short it would be of great benefit to read over the two chapters I mentioned above, and the manual in question can be located in your ...\cvi\manuals directory as the usermanl.pdf file.

Jason F.
Applications Engineer
National Instruments
www.ni.com/ask
0 Kudos
Message 2 of 2
(3,049 Views)