Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

check GetTerminalNameWithDevPrefix

The sample C/C++ code for NIDAQmx contains the lines:
if( productCategory!=DAQmx_Val_CSeriesModule && productCategory!=DAQmx_Val_SCXIModule )
   *triggerName++ =
'/';
   strcat(strcat(strcpy(triggerName,device),
"/"),terminalName);
   break;
 
Should the last 3 lines be enclosed in brackets (i.e. {})?  For example:
if( productCategory!=DAQmx_Val_CSeriesModule && productCategory!=DAQmx_Val_SCXIModule )
   {

   *triggerName++ =
'/';
   strcat(strcat(strcpy(triggerName,device),
"/"),terminalName);
   break;
   }

Thanks,

 

Ian

 
Message 1 of 15
(5,513 Views)
Hey Ian,
 
Could you please elaborate a little more on which example you are looking at and where you found it. It depends on if only the statement right after the if condition needs to be executed or everything after the if condition. So, if you could tell us where exactly you found this code it will help us better understand what is going on in the code.
 
Best Regards,
 
Raajit L | Applications Engineer | National Instruments
Raajit L
National Instruments
0 Kudos
Message 2 of 15
(5,470 Views)

The function GetTerminalNameWithDevPrefix is used in the sample source code that illustrates how to synchronize multiple devices (NI-DAQ\Examples\DAQmx ANSI C\Synchronization\Multi-Device\Continuous AI\ContinuousAI.c) as well as how to synchronize AI an DI (NI-DAQ\Examples\DAQmx ANSI C\Synchronization\Multi-Function\ContAI-Read Dig Chan\ContAI-ReadDigChan.c).  I suspect this function can be found in a number of other samples.

Thanks,


Ian

0 Kudos
Message 3 of 15
(5,463 Views)

Hello Ian,

It seems as if the code is actually meant to be doing that. The "strcat(strcat(strcpy(triggerName,device),"/"),terminalName);" function needs to be executed every time in the code. Please notice that the triggerName is actually used in this function. On the other hand if the IF CONDITION (if( productCategory!=DAQmx_Val_CSeriesModule && productCategory!=DAQmx_Val_SCXIModule )) is not met only then does the triggerName need to be appended with a "/". This is just checking to make sure that the triggerName is in the right format before it is used in the function right after it.

Best Regards,

Raajit L | Applications Engineer | National Instruments

Raajit L
National Instruments
0 Kudos
Message 4 of 15
(5,435 Views)

Hello Raajit,

Thank you for the information.  If I might make a small suggestion, the indentation in the sample code could be removed to avoid any possible misinterpretation.  For example:

if( productCategory!=DAQmx_Val_CSeriesModule && productCategory!=DAQmx_Val_SCXIModule ) {
   *triggerName++ =
'/';
}
strcat(strcat(strcpy(triggerName,device),"/"),terminalName);
break;

Thanks,

Ian

0 Kudos
Message 5 of 15
(5,432 Views)

Hello Raajit,

There is one point I would like to understand before closing this posting.

The function GetTerminalNameWithDevPrefix uses a while loop:
while( i<=numDevices ) {
      ...
    break;
}

Because of the 'break' , the statements within this 'while loop' only get executed once.  So what is the purpose of having a 'while  loop' ?

The effect of having a 'while loop' plus indenting the line containing the 'strcat( strcat... ) )' function call produces code that, from a visual point of view, is confusing and more than a little ambiguous as to intended functionality. 

Just to be clear, would you please confirm to confirm that the 'while loop' can be safely removed and that the actual operation performed by this GetTerminalNameWithDevPrefix is actually suppose to be as follows:

static

int32 GetTerminalNameWithDevPrefix(TaskHandle taskHandle, const char terminalName[], char triggerName[])
{
int32 error=0;
char device[256];
int32 productCategory;

DAQmxErrChk (DAQmxGetNthTaskDevice(taskHandle,1,device,256));
DAQmxErrChk (DAQmxGetDevProductCategory(device,&productCategory));
if( productCategory!=DAQmx_Val_CSeriesModule && productCategory!=DAQmx_Val_SCXIModule )
         *triggerName++ = '/';
strcat(strcat(strcpy(triggerName,device),"/"),terminalName);

Error:
return error;
}

Best regards,

Ian

 

0 Kudos
Message 6 of 15
(5,417 Views)
Hello Ian,

Could you please tell me which file exactly did you find this code in, so that I can look over that. I did find where it is being used in the example, but I would like to see the actual code as well.

Thank you for your time.

Regards,

Raajit
Raajit L
National Instruments
0 Kudos
Message 7 of 15
(5,399 Views)

Hello Raajit,

Please refer to my message of 02-16-2007 01:10 PM.

Ian

 

0 Kudos
Message 8 of 15
(5,395 Views)
This was reported to R&D (# CAR ID 45L7LTQZ) for further investigation. A possible workaround would be to add the brackets after the if statement and after the break statement. Thanks for the feedback!

Regards,

Raajit Lall
Applications Engineer
National Instruments

Message Edited by Raajit L on 02-22-2007 04:32 PM

Raajit L
National Instruments
0 Kudos
Message 9 of 15
(5,370 Views)

Hello Raajit,

The work around solution you suggest is no different from what I suggested earlier.  My question was is it sufficient or does it require the 'while loop'?   If you do not know then do you have an idea of how long it might take for your R&D department to respond to report # CAR ID 45L7LTQZ? 

Best regards,

Ian

 

0 Kudos
Message 10 of 15
(5,358 Views)