09-07-2010 07:51 AM
Hello,
I want to use the NI-GPIB-USB controller as a device. After one week search I found only a single sample code for National Instruments GPIB !!, unfortunately that is written in “C” not in C#.
I can send strings from Unix System to Windows PC but I cannot read it. I have problems with “Board.BeginRead” and “Board.EndReadString”.
When I run the program I am getting the error message “EndReadString was called before BeginRead”.
I am attaching the code here (I am new to GPIB and C#), it will be a great help for me if some one can give any information which can help this problem.
09-07-2010 09:26 AM
I found it,
Where I call "BeginRead" I forgot to add the number of bytes (a 7), So it should look like below.
// Initiates a read to a device asynchronously
board.BeginRead(7,new AsyncCallback(endread), null);
10-07-2011 06:24 AM
Did you finally made it or refined your code?
I habe the same problem. Do you use a handle to a device or to the board? And do you use the Notify method to automatically read the command send by the controller or did you implement it analog to the C - examples (with a thread polling the ibsta flags and doing something when, for example, "if ((ibsta&LACS)&&(!(ibsta&ATN)))"
is true) ?
Thank you for every hint..
10-09-2011 02:07 PM
Hello, I don’t have the final code with me and as far I remember I Waite until one of the needed GPIB status flag occurs and rest is depends on the received status flag.
GpibStatusFlags mask = (GpibStatusFlags.ListenerAddressed | GpibStatusFlags.TalkerAddressed | .. .);
//Waite until one of the GPIB status flag occurs
board.Wait(mask);
10-10-2011 05:53 AM
Thank you very much for your answer!
...but the wait function is blocking until anything happens, right? Did you create an extra thread for board.wait() or does it not matter for you if the program blocks? Do you know a way using the board.notify() method?
Greetings from Germany, Christian
04-11-2012 06:04 AM
I am still working on it so that I can run the all the GPIB functions in a single worker thread.
I use the "Board" for using the PC as a GPIB device and "Device" for using the PC as a GPIB controller.
05-10-2012 08:24 AM
Yes I did it.
Need no extra thread for board.wait(). I run the function which contains the while() loop (or GPIB device loop, this includes listening, talking on GPIB) in a separate thread and set that thread as back ground worker. For displaying the GPIB status and messages I use Invoke so, that is also working independent.
07-13-2012 07:23 AM
Few interesting documents which includes informations about > Device & Board functions, Waiting for GPIB Conditions, Asynchronous Event Notification in NI-488.2 Applications and so on.
07-13-2012 07:24 AM
Few interesting documents which includes informations about > Device & Board functions, Waiting for GPIB Conditions, Asynchronous Event Notification in NI-488.2 Applications and so on.
07-13-2012 07:26 AM
Few interesting documents which includes informations about > Device & Board functions, Waiting for GPIB Conditions, Asynchronous Event Notification in NI-488.2 Applications and so on.