07-07-2008 06:54 PM
I am currently working with LabWindows/CVI, and I am trying to query spectrum analyzer trace data (comma
separated data) into an ASCII format array (str_trace[]), where I use the
following three different kinds of commands; however, neither works.
No.1: ViQueryf(HP_E4407B, "TRAC:DATA? TRACE1 \n", "%s\n", &str_trace);
No.2: sprintf(write_buffer,"TRAC:DATA?TRACE1 \n");
Send(0,HP_E4407B,write_buffer,strlen(write_buffer),1);
Receive(0,HP_E4407B,read_buffer,numToRead,256);
sscanf(read_buffer,"%s\n",&str_trace);
No.3: sprintf(write_buffer,"TRAC:DATA?TRACE1 \n");
ibwrt(HP_E4407B,write_buffer,strlen(write_buffer));
ibrd(HP_E4407B,read_buffer,numToRead);
sscanf(read_buffer,"%s\n",&str_trace);
After getting the arry of str_trace, I am doing the following to separate them:
char *result=NULL;
result=strtok(str_trace,",");
while(result!=NULL){
data[i]=atof(result);
result=strtok(str_trace,",");
i=i+1;
}
Please help me to point out where the errors are. Thanks a lot!
07-07-2008 09:23 PM
07-08-2008 12:30 AM
What is the HP_E4407B parameter in your examples ? How do you set it ? For the first example it should be an instrument handle , returned by viOpen();
07-08-2008 07:57 AM
07-08-2008 09:59 AM
07-08-2008 10:15 AM
Hi NathanT,
Thanks for your suggestion. However, is any possible ways I could just write several commands to do this, like I shows in my previous post? Thanks!