NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle CVI uir calls in TestStand to be able to process events

I need to be able to update and process system events from a user interface that is in a CVI DLL, this DLL is called from TestStand and the problem is that if I use the RunUserInterface () call inside my DLL then I can't continue to run my test sequence because TestStand is waiting for this module to come back. I need to be able to see this user interface trough the test sequence execution.
0 Kudos
Message 1 of 10
(4,373 Views)

Hi Verdulken,

try to put your cvi dll call into a subsequence and calls them as a new Thread or a new Execution...


@Verdulken wrote:
I need to be able to update and process system events from a user interface that is in a CVI DLL, this DLL is called from TestStand and the problem is that if I use the RunUserInterface () call inside my DLL then I can't continue to run my test sequence because TestStand is waiting for this module to come back. I need to be able to see this user interface trough the test sequence execution.



Luigi Magni (System Engineer - CTA)
0 Kudos
Message 2 of 10
(4,361 Views)
Hi, I tried that but when I make calls to this same DLL in other parts of the test sequence they don't update the UI. I think is because is on a different thread it opens another instance of the DLL. Thanks for the help.
0 Kudos
Message 3 of 10
(4,347 Views)
You are right, you don't have to call the same call to the dll function you can change parameters to the sequence (of course by reference) and you can update the ui reading the TS variable (using a timer), or calling another dll function that act onto the ui using a static reference of the opened panel...
 
Try these ways I assure that are ok.
Luigi Magni (System Engineer - CTA)
0 Kudos
Message 4 of 10
(4,328 Views)
Hey !!!! good tip, that seems to work so far. What I did is pass the panel handle of the OI to TestStand and run this OI on a different thread, so whenever I need to modify the panel I just pass the handle from TestStand to the DLL and it works great, this way I can also run the user interface events.
 
Thanks for the help
0 Kudos
Message 5 of 10
(4,314 Views)

I'm pleased to helped you.

We have already encountered this kind of "troubles" starting from TS 1.1 on 2001...

Are you from Germany?

Luigi Magni (System Engineer - CTA)
0 Kudos
Message 6 of 10
(4,301 Views)
I'm actually from the US (well, originally from Mexico) but I have used this user name in a lot of instances for a long time, I read it from a world war II sign when I was in Germany. My real name is Jose.
 
This is the first time I use CVI with TestStand, I used CVI for years now but never with TestStand, only LabVIEW.
 
R U in the US ?
0 Kudos
Message 7 of 10
(4,296 Views)

Dear Jose,

I'm from Italy I was in US several time the last was in 2005 in Austin for NiWeek for my company that is an Alliance in Italy.

We use TS from 2001 either with LV and CVI in order to optimize code and share tasks.

Just for curiosity, but I also know German language (I have made some part of my engineering study also in Austria) and I know the word "Verdunkeln" (that means to darken or to mask) but no "Verdulken" as you wrote as user name...

Regards


@Verdulken wrote:
I'm actually from the US (well, originally from Mexico) but I have used this user name in a lot of instances for a long time, I read it from a world war II sign when I was in Germany. My real name is Jose.
 
This is the first time I use CVI with TestStand, I used CVI for years now but never with TestStand, only LabVIEW.
 
R U in the US ?



Luigi Magni (System Engineer - CTA)
0 Kudos
Message 8 of 10
(4,294 Views)

Cool !!! I was in Italy in 1999 for 2 weeks, beautiful place. I think I just misspelled the name. I have another big problem now, maybe you could help me which I would really appreciate.

I need to load a comma delimited file to use in my program so I'm calling a function on my CVI DLL that loads the file and parses it, the problem is that when I call the function TestStand crashes and the problem seems to be the size of the arrays (due to stack size I think) because if I lower the arrays size and file size it works fine, the file is around 800Kbytes in size. Here is the function I wrote to do this:

int Load_Param_File (char *fileName)
{
 int paramFile;
 int no_args;
 int i,j;
 int error;
 
 char *ptr;
 //char *tmpstr;
 //char *arg;
 char tmpstr[PARAM_FILESIZE];
 char arg[MAX_PARAM_ROWS+1][4000];
 //arg = (char*)malloc((MAX_PARAM_ROWS+1)*4000*sizeof(char));
 //tmpstr = (char*)malloc(PARAM_FILESIZE*sizeof(char));
 
 
 /* Open file for read only purposes */
 paramFile = OpenFile (fileName, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_ASCII);
 /* read file and place contents into tmpstr */
 error = ReadFile (paramFile, tmpstr, PARAM_FILESIZE);
 /* Close file */
 CloseFile (paramFile);
 if (error > 0) {
  /* Parse String */
  ptr = strtok(tmpstr, "\n");      // separate rows first
  for (i=0;i<=MAX_PARAM_ROWS && (ptr != NULL); i++) {
   strcpy(arg[i],ptr);
   ptr = strtok(NULL, "\n");
  }
  /* Parse into table */
  for (i=0;i<=MAX_PARAM_ROWS; i++) {
   ptr = strtok(arg[i],",");     // separate columns
   for (j=0;j<=MAX_PARAM_COLS && (ptr != NULL); j++) {    
    strcpy(parameters[i][j],ptr);
    ptr = strtok(NULL, ",");
   }
  }
 }
 
 return error;
}

The array parameters is a global in my DLL. The code that is commented is another thing I tried, I didn't get the error but I don't get any data in the parameters array after it runs.

I really appreciate your help and thanks in advance. 

Jose

0 Kudos
Message 9 of 10
(4,291 Views)

Dear Jose,

your CVI code is plenty of possible error cause you don't make a boundary check of your array allocations so you can incour in buffer overflow... First of all is a good idea to use dynamic buffer but remember to free them at the end (also in case of error)...

Could be usefull if you read the file size (GetFileSize) before doing the allocation of the main file buffer 'tmpstr' in order to size them...

After that use 'strncpy' instead of 'strcpy' in order to assure that you limit the copy to your buffer size dim...

Last do an accurate debug session in order to discover your code failure...

Sincerely

 

Luigi Magni (System Engineer - CTA)
0 Kudos
Message 10 of 10
(4,246 Views)