02-08-2016 12:55 PM
Hello,
I would like to create a GPIB listener. I use a NI PCIe-GPIB card. Controller Primary address is 0, and listener address is 1.
For the listener, i created objects as in the followings:
_board = new Board(0);
_board.Reset();
_board = new Board(0);
_board.IOTimeout = TimeoutValue.T1s;
_board.IsSystemController = false;
_board.ListenOnlyMode = true;
_board.PrimaryAddress = 1;
_board.SecondaryAddress = 0;
_board.SynchronizeCallbacks = true;
_device = new Device(0, 0);
_device.IOTimeout = TimeoutValue.T1s;
In a thread, I try to trap events such as Notify function on a IO Complete,
_device.Notify(GpibStatusFlags.IOComplete, new NotifyCallback(IOCompleteCallback), null);
or BeginRead async call
_device.BeginRead(new AsyncCallback(ReadCompleted), null);
None of them works, when Controller try to locate listeners by *IDN? key, Actually, controller sees there is a listener, but they cannot communicate, it throws timeout error.
My question is what can i do on Listener side to be able to trap Queries from Controller side, and reply them
Thank you so much for your help
02-09-2016 02:22 PM
Hi freewalks,
Thanks for posting on the Discussion Forums to get support with your GPIB issue. I have just a few questions to try and get to the heart of the problem.
After looking at your c# code, it appears that you instantiate an instance of Board twice (new Board, board.reset(), new Board(0)). Is there a specific reason you're doing this? Or did you mean to listen to another board?
Have you been able to run any GPIB code successfully with this board? You can try running one of the shipping examples that install with the 488.2 driver, located at C:\Users\Public\Documents\National Instruments\NI-488.2\Examples\DotNET4.5.1\SimpleAsynchronousReadWrite\cs . Do the other examples still timeout?
I'm also curious what hardware and software you're using. You said you're using the NI-PCIe-GPIB board. What other hardware are you talking or listening to? Are you also using the NI 488.2 driver? What version are you using? And are you using that with Visual Studio or Measurement Studio? What version do you have of those?
Any information you could provide will allow everyone on the Forums to get you an answer more quickly.
02-11-2016 08:59 AM
Hi Austin,
These examples work only if you are the controller. I want to be on other side, Listener. I somehow managed to write a code for being a listener, and it works great. What I do is I created timer callbacks to periodically sniff the GPIB lines for Reads. Of course, not every Read attempt is succesful, and it throws a timeout error. I handle this error by just ignoring it. However, after a while, because of numerous periodic Read fails, some errors such as "input handle is invalid" or "driver error" are thrown, and i reinitialize board and device to handle error.
My question is the method i came up with is a good example or not. Im seeing Notify function in the NI-488.2 library, but I never made it work in a way that I want. Basically I would like to get warned about a message received through GPIB line in an interrupt service fashion.
I have NI 488.2 3.1.2 and NI-VISA 5.4.1 installed, but I use NI 488.2 library to communicate via GPIB in a C# code. I use Visual Studio 12 for this reason.
I can't use NI-Visa for GPIB communication. Since listener side is empty as long as I don't run my code, NI-VISA cannot see an active listener on the other side, and doesn't return a resource address to open up a session.
I have another question, what is the equivalent command in NI-488.2 for GPIBSession.ReadStatusByte in NI-VISA. It is because I check any message avaliable or not with this command.
Thanks a lot for your support!!!
02-12-2016
05:03 PM
- last edited on
01-10-2025
02:52 PM
by
Content Cleaner
Hi freewalks,
I think what you're doing with the notifier functions makes sense, and can generally turn your GPIB device into a pseudo-listener. I can't say for sure because it doens't appear we have any published examples that demonstrate that functionality. I do have two recommendations, though. The first is reading through this paper about Asynchronous Callback Functions provided me some good insight on how you might imoplement the notifiers. I know it discusses windows 95/98, but I assume it will operate in a similar manner on newer machines.
I would also recommend updating your 488.2 driver if possible. I know there have been a fair amount of bug fixes in the more recent versions, so I've linked the download page to 488.w 14.0 download. I'm not sure the specifics on why your listener example isn't working, but it very well may be due to a bug from an older version of 488.2
https://www.ni.com/en/support/downloads/drivers/download.ni-488-2.html
NI-488.2 Function Reference Manual for Windows -
https://www.ni.com/docs/en-US/bundle/321038g/resource/321038g.pdf