I have a NI GPIB-USB-HS adapter running the 488.2 3.1.2 drivers.
It runs a C app in listen-only mode and captures bus data strings well.
I'm trying to get the same functionality using C#.Net.
So far I have tried the following code snippet in VS2010 (.Net 4.0)
with the corresponding NI 488.2 and Common assemblies referenced by the project.
Here is a snippet...
Form...
private Board board = null;
Form_Load...
try {
board = new Board(0); // ibfind(GPIB0);
board.Reset(); // ibonl();
board = new Board(0); // ibfind(GPIB0);
board.ListenOnlyMode = true; // ibconfig(GPIB0, IbcLON, 1)
board.IOTimeout = Timeoutvalue.t300ms; // ibconfig(GPIB0, IbcTMO, T300ms)
}
catch {
...
}
Form_Shown...
while(running)
{
Application.DoEvents();
try {
data = board.ReadByteArray(256); // ibrd
length = board.LastCount; // Ibcnt
}
catch {
...
}
}
With the NI GPIB-USB-HS adapter disconnected from any GPIB host or devices,
the ReadByteArray lands in the catch every 300ms per the timeout value as expected.
With the NI GPIB-USB-HS adapter connected to a GPIB host and devices with data flowing,
the ReadByteArray method ends up in the catch everytime still and the length is always 0.
Polling in C (ibrd/Ibcnt) is the only way I have been able to get Listen-Only to work.
What needs to be done in .Net to make Listen-Only work?
Here is a list of the calls in C that I use for Listen-Only to work...
Setup...
Bd = ibfindA("GPIB0");
ibonl(Bd, 0); // Take board offline - loses handle
Bd = ibfindA("GPIB0");
ibconfig(Bd, IbcSAD, 0x00);
ibconfig(Bd, IbcLON, 1);
ibconfig(Bd, IbcTMO, T300ms);
Poll...
ibrd(Bd, ReadBuffer, 256);
length = Ibcnt();
Thanks,
Steve