Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

ibcunaddr involves error

Hello,
 
I connect 2 pc over a GPIB connection. One device is set in non-controller and the other in controller mode.
On non-controller device, function "ibnotify" is used to read data from controller device. The callback return is set on LACS. But after reading data, LACS bit is still set on. Therefore, I always try to read data and then get timeout error.
 
That 's why, I try to set the controller device in UNL/UNT mode using ibconfig (board, IbcUnAddr,  1). This function always returns an error 23 (EDHL).
Is there something else to do before settind "IbcUnAddr) ?
 
Program of controller device :
board = ibfind ("GPIB0");
ibrsc (board, 1);
ibsic (board);
ibconfig (board, IbcUnAddr, 1);  => Error 23 (0x8000, EDHL)
ibwrt (board, "TOTO", 4);
 
Thanks for your help.
 
Zaboulou
0 Kudos
Message 1 of 5
(3,639 Views)

Hello Zaboulou,

The reason you are getting an error is because you are trying to change a device level property on a board.  Since you are using ibfind, you are opening a board level descriptor.  In the documentation for ibconfig (NI-488.2 Help file), you will see that IbcUnAddr is a device level property.  You can use ibdev instead of ibfind to open a device level descriptor.

Instead of using the same ibnotify mask, you should disable waiting for LACS when calling ibnotify after reading (only listen for other events).

I hope this helps.

Steven T.

Message 2 of 5
(3,624 Views)

Hi Steven,

Thanks for your answer.

There is no more error if I use ibdev (instead of ibfind) and then ibconfig with IbcUnAdrr parameter. If I follow your advice, I should have an error if I try to set IbcPad after ibfind calling. But no error appears ... Do you have any idea ?

Anyway, when I configure my controller device to UNL/UNT mode, it seems that LACS is still set to 1 because after executing my callback, the program re-excutes my callback. I don't want to re-enter in my calback. All of my events are reading. That s why I set enable LACS return in my callback.

In the attached file, my callback is GPIB_Callback and ibnotify function is in Init_GPIB function, which I call at the beginning of my program.

Thanks for your help.

Zaboulou

0 Kudos
Message 3 of 5
(3,606 Views)

Zaboulou,

From your description, your callback will return under a variety of conditions.  The first thing to do in this callback should be to see if you are addressed as talker, listener, or any other event you care about.  Inside the if statement for each event, you need to disable listening for that event again.  So if you get a talker addressed event, enable your events except for talker.  This way you will not go into your callback function twice for the same event.  Here is some code that uses a similar strategy.  It uses polling instead of callbacks, but you can get the general idea.

I hope this helps.

Steven T.

0 Kudos
Message 4 of 5
(3,593 Views)

Hi Steven,

Thx for your answer. It works now. I have to use multithreading application but it ll be alright.

Zaboulou.

0 Kudos
Message 5 of 5
(3,583 Views)