AnsweredAssumed Answered

Reading binary data from 66321B/data logger C & NI-VISA

Question asked by jphidalgo on Jan 25, 2008
Hi,
I am developing a small application to use the 66321B current logging function.

Everything works fine when using ASCII mode, but if I try to use binary transfer, I get meaningless results.

I am using Visual Studio 2008 and C#, with NI VISA and a PCMCIA GPIB adapter.

I have been browsing throug the forums and got this one with a similar problem under VB... (sorry, this is my first post and cannot post links)

However, the solution posted there does not work for me.

My VISA initialization code is:

"
                mbSession = (MessageBasedSession)ResourceManager.GetLocalManager().Open(resourceDescriptor);
                mbSessionReader = new MessageBasedSessionReader(mbSession);
                mbSessionReader.BinaryEncoding = BinaryEncoding.DefiniteLengthBlockData;

"


The code that actually reads the data from the device is:
"
                mbSession.Timeout = 5000;
                mbSession.Write("INIT:NAME DLOG");
                mbSession.Write("TRIG:ACQ");
                mbSession.Write("FORM:DATA REAL,64; BORD NORM");
                results = mbSessionReader.ReadDoubles(3);
                for (int i = 0; i < 3; i++)
                    output.WriteLine(results[i]);

"

The output variable is just a stream to a file. However, when this code runs, I get an exception:
"
A format specifier in the format string is invalid. VISA error code -1073807297 (0xBFFF003F), ErrorInvalidFormat System.Collections.ListDictionaryInternal
"


Is there any function that would return the number of data elements contained in the info block received from the instrument (I know that the information block contains the length of the data contained in it)?

I am guessing that reading the doubles directly from the array returned by the MessageBasedSession could by a work around...  

Outcomes