I am currently working with LabWindows/CVI, and I am trying to retrieve trace data (comma separated data) from spectrum analyzer (Agilent E4407B) into an ASCII format array (str_trace[]), where I use the
following three different kinds of commands; however, neither of them works.
No.1: ViQueryf(E4407B, "TRACATA? TRACE1 \n","%s\n",&str_trace);
No.2: sprintf(write_buffer,"TRACATA?TRACE1 \n");
Send(0,E4407B,write_buffer,strlen(write_buffer),1);
Receive(0,E4407B,read_buffer,numToRead,256);
sscanf(read_buffer,"%s\n",&str_trace);
No.3: sprintf(write_buffer,"TRACATA?TRACE1 \n");
ibwrt(E4407B,write_buffer,strlen(write_buffer));
ibrd(E4407B,read_buffer,numToRead);
sscanf(read_buffer,"%s\n",&str_trace);
In order to save the data point into the array one by one without the comma, all of them are followed by:
char *result=NULL;
result=strtok(str_trace,",");
while(result!=NULL){
data[i]=atof(result);
result=strtok(str_trace,",");
i=i+1;
}
Please do me a favor to point out where my errors are. Thanks a lot!
following three different kinds of commands; however, neither of them works.
No.1: ViQueryf(E4407B, "TRACATA? TRACE1 \n","%s\n",&str_trace);
No.2: sprintf(write_buffer,"TRACATA?TRACE1 \n");
Send(0,E4407B,write_buffer,strlen(write_buffer),1);
Receive(0,E4407B,read_buffer,numToRead,256);
sscanf(read_buffer,"%s\n",&str_trace);
No.3: sprintf(write_buffer,"TRACATA?TRACE1 \n");
ibwrt(E4407B,write_buffer,strlen(write_buffer));
ibrd(E4407B,read_buffer,numToRead);
sscanf(read_buffer,"%s\n",&str_trace);
In order to save the data point into the array one by one without the comma, all of them are followed by:
char *result=NULL;
result=strtok(str_trace,",");
while(result!=NULL){
data[i]=atof(result);
result=strtok(str_trace,",");
i=i+1;
}
Please do me a favor to point out where my errors are. Thanks a lot!
If you have an NI-compatible or Prologix GPIB card, and can use a standalone command-line application to fetch your CSV trace data, I can probably help out with that.