Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

No Listeners on Bus

Hi,

i am trying to get a simple applicaiton to write to a gpib device. the interface is a GPIB-ENET device. i open the interface using ibdev, clear the device using ibclr, check if the device exists using ibln and then write the string " E " to the device (a 2100 computotor indexer). all the commands except the ibwrt return a 0x100 status and no error. the ibwrt returns an ENOL error.

i have tried this same command with the gpib interactive interface gpibintctrl using only ibdev and ibwrt and the command suceeds.

can someone help me witrh what i am doing wrong please.

i have attached the source code.

thanks in advance

regards
sean


#include
#include
#include
#include "ni488.h"

#define ARRAYSIZE 1024 // Size of read buffer

#define ESCAPE 0x1b

// Response byte after serial polling device.
#define SERIALPOLLRESPONSE 0x60

int Dev[8][31];

char ValueStr[8][31][ARRAYSIZE + 1];

char ErrorMnemonic[21][5] = {"EDVR", "ECIC", "ENOL", "EADR", "EARG",
"ESAC", "EABO", "ENEB", "EDMA", "",
"EOIP", "ECAP", "EFSO", "", "EBUS",
"ESTB", "ESRQ", "", "", "", "ETAB"};

char errmsg[1024], str[1024];

int device, ud, board;
long count;

void main(int argc, char *argv[]) {

short exists;

device = 3;
ud = ibdev(board,device,0,13,1,0);
sprintf(errmsg,"Opening GPIB device on board %d at primary address %d. Error = %d. Status = 0x%x\n", 0, device, iberr, ibsta);
printf("%s",errmsg);

ibclr(ud);
sprintf(errmsg,"Clearing GPIB device on board %d at primary address %d. Error = %d. Status = 0x%x\n", 0, device, iberr, ibsta);
printf("%s",errmsg);

ibln(board,device,0,&exists);
sprintf(errmsg,"Checking GPIB device on board %d at primary address %d. Error = %d. Status = 0x%x\n", 0, device, iberr, ibsta);
printf("%s",errmsg);
printf("Device at adress %d exists status = %d\n",device,exists);

strcpy(&str[0]," E ");
count = strlen(str);
ibwrt(ud,&str[0],count);
sprintf(errmsg,"Writing to GPIB device %d on board %d at address %d, %d number of characters. Error = %d. Status = 0x%x.\nString : \"%s\", count = %d\n",ud,0,device, count, iberr, ibsta, str, ibcntl);
printf("%s",errmsg);

}
0 Kudos
Message 1 of 7
(4,554 Views)
What version of the driver are you using?
Does the device show up in MAX?
Does MAX show the device at PAD 3 as well?
Are you sure your board is the CIC?  Try sending ibsic before ibclr.

Hope this helps,
Robert Mortensen
Software Engineer
National Instruments
0 Kudos
Message 2 of 7
(4,541 Views)
yes, the device shows up in max. using max i can address the device and write to it. the board seems to be in cic. after stuffing around a bit, i have managed to talk to the device by inserting a sleep of one second after issueing ibdev. after that i can write toi the device without a problem. any ideas as to why?

maybe a device that requires slower time responses?

tia
0 Kudos
Message 3 of 7
(4,519 Views)
Is this an older, slower instrument?  It is very possible that it simply takes a longer amount of time to assert itself as a listener.
Robert Mortensen
Software Engineer
National Instruments
0 Kudos
Message 4 of 7
(4,515 Views)
yes, about at least 20 years old.  it was originally run on a PDP-11 with RSX11M+ and then on an HP700 C100 workstation running HP-UX 10.20. 
0 Kudos
Message 5 of 7
(4,511 Views)
I'm not sure why pausing after the ibdev would help, but I noticed a couple of things from your code:

You don't seem to be initializing the board variable, so it could be the device handle is to the wrong board.

Also, you have mixed in a board-only ibln call with device calls, which is not recommended.

-Dan
0 Kudos
Message 6 of 7
(4,486 Views)
cocnerning the code, i noticed that and sorted it out by setting it to the appropriate value (0 in this case). i also removed all the various code that has board level calls and still require a delay. i have not experimented with how long the delay needs to be, however. i have attached the code.

#include
#include
#include
#include
#include "ni488.h"

int device, ud, board;

void main(int argc, char *argv[]) {

char errmsg[1024], str[1024];

long count;

short exists;

device = 1;
ud = ibdev(0,device,0,10,1,0);
sprintf(errmsg,"Opening GPIB device on board %d at primary address %d. Error = %d. Status = 0x%x\n", 0, device, iberr, ibsta);
printf("%s",errmsg);

sleep(1);

strcpy(&str[0]," E ");
count = strlen(str);
ibwrt(ud,&str[0],count);
sprintf(errmsg,"Writing to GPIB device %d on board %d at address %d, %d number of characters. Error = %d. Status = 0x%x.\nString : \"%s\", count = %d\n",ud,0,device, count, iberr, ibsta, str, ibcntl);
printf("%s",errmsg);

sleep(30);

strcpy(&str[0]," Z ");
count = strlen(str);
ibwrt(ud,&str[0],count);
sprintf(errmsg,"Writing to GPIB device %d on board %d at address %d, %d number of characters. Error = %d. Status = 0x%x.\nString : \"%s\", count = %d\n",ud,0,device, count, iberr, ibsta, str, ibcntl);
printf("%s",errmsg);
}
0 Kudos
Message 7 of 7
(4,481 Views)