Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Inclomplete message while binary read if 0x00 occures

Solved!
Go to solution

Hallo Forum Members,

 

I just run into trouble reading a trace from an FSP13 with FORMAT REAL,32.

 

I hunted the issue down to the point, that the trace is incomplete after the

first occurence of a 0 in the binary data, so more or less data are read,

depending on the position of the 0.

 

I compared the REAL,32 trace with an ASC trace and could exactly locate the0x00

in the Ascii trace.0. The message ends regularly with ibsta = END,CMPL.  and also

no "system:err?" is reported.

 

What do I do?

 - I use libgpibapi.so under linux i686 (loaded via ctypes into python), HW is an NI-PCI-Card,

   Here is the fragment, what I'm currently doing:

 

 

self.gpib_so.ibdev(self.boardid, self.pad, 0, tmout, 1, 0) # ==> EOI is used and not EOS
self.ibwrt("FORMAT REAL,32")
self.ibwrt("TRACE? TRAC1")
x = ""
while 1:
    x += self.ibrd()
    if self.ibsta & END:
break

 

Any help is apreciated, maybe there is something to configure on the FSP13.

 

Thanks, Axel

0 Kudos
Message 1 of 2
(2,982 Views)
Solution
Accepted by topic author Axel Wachtler
It turned out that the ctypes string buffer caused the issue.
This buffers had two members, buffer.value and buffer.raw.
buffer.value just returns an 0 terminated string. buffer.raw returns
the entire allocated buffer. To get the real number of received
bytes, you need to access the global variable ibcntl in the gpib
library. Under windows this variable is renamed to user_ibcntl.
(found here: http://www.ni.com/white-paper/4873/en)
0 Kudos
Message 2 of 2
(2,946 Views)