03-20-2014 02:38 AM
I want to capture a .gif file from a spectrum analyzer and save the file in PC, but I've got a problem when read data from the instrument. I'm not sure how to format the string got from the instrument , When I use "%s" or "%t" as the read string format the data got from the instrument is truncated.
my code are as follows, could anyone tell me where i am wrong?
char resultsArray[5000];
viPrintf(hSpectrumInstr, ":MMEM:STOR:SCR 'C:PICTURE.GIF'\n");
viQueryf(hSpectrumInstr, ":MMEM:DATA? 'C:PICTURE.GIF'\n", "%t", resultsArray);
printf("%s", resultsArray);
getchar();
Solved! Go to Solution.
03-20-2014 02:51 AM
For raw / binary data you might try the %b or %y specifier, see here
03-20-2014 03:52 AM
Hi wolfgang
it seemed that %b or %y is not accepted by the read string format. the run-time error is like this:
NON-FATAL RUN-TIME ERROR
"Spectrum Alnalyzer.c",line 29, col 5, thread id 0x00004284
Function viQueryf: (return value == -1073807297 [0xbfff003f])
the string format modifier is not valid.
03-20-2014 03:58 AM
forgot to tell , my spectrum analyzer is Agilent E4447, is it possible that the string format for this instrument is not the same as the specifier mentioned in "Using VISA Formatted I/O in Instrument Driver Development"?
03-20-2014 03:58 AM
So how is your modifier? Can you post the relevant line?
03-20-2014 04:01 AM
char resultsArray[5000];
viPrintf(hSpectrumInstr, ":MMEM:STOR:SCR 'C:PICTURE.GIF'\n");
viQueryf(hSpectrumInstr, ":MMEM:DATA? 'C:PICTURE.GIF'\n", "%b", resultsArray);
03-20-2014 04:05 AM - edited 03-20-2014 04:15 AM
as you may see your code is unreadable, can you post a screenshot or, as before, a Word document?
When using '%b' the array should be of type ViInt8
03-20-2014 07:44 PM
sorry so late to reply, my code is in the following word:
03-20-2014 11:36 PM
did you try declaring your array as type ViInt8 ?
03-21-2014 01:30 AM
Yes, I've tried declaring the variable 'resultArray' to ViInt8, it also doesn't work. It's strange the "%b" and "%y" are declared invalid for the string format modifier. I used the NI Max to communicate with the analyzer, it can read back correct data, so i think my code relevant with capture pic probablly has problem.