int vxi11_open_device(const char *ip, CLINK *clink, char *device) { int ret; int l; int device_no=-1; for (l=0; l<VXI11_MAX_CLIENTS; l++){ if (strcmp(ip,VXI11_IP_ADDRESS[l]) == 0 ) { device_no=l; } } if (device_no < 0) { if (VXI11_DEVICE_NO >= VXI11_MAX_CLIENTS) { printf("Error: maximum of %d clients allowed\n",VXI11_MAX_CLIENTS); ret = -VXI11_MAX_CLIENTS; } else { ret = vxi11_open_device(ip, &(clink->client), &(clink->link), device); strncpy(VXI11_IP_ADDRESS[VXI11_DEVICE_NO],ip,20); VXI11_CLIENT_ADDRESS[VXI11_DEVICE_NO] = clink->client; VXI11_LINK_COUNT[VXI11_DEVICE_NO]=1; VXI11_DEVICE_NO++; } } else { clink->client = VXI11_CLIENT_ADDRESS[device_no]; ret = vxi11_open_link(ip, &(clink->client), &(clink->link), device); VXI11_LINK_COUNT[device_no]++; } return ret; }
int main(int argc,char **argv) { static char *progname; static char *serverIP; char comm[256]; long bytes_returned; BOOL got_ip=FALSE; BOOL got_comm=FALSE; int index=1; CLINK *clink; /* client link (actually a structure contining CLIENT and VXI11_LINK pointers) */ char outputbuf[BUF_LEN]; clink = new CLINK; /* allocate some memory */ progname = argv[0]; while(index<argc){ if(sc(argv[index],(char*)"-ip")||sc(argv[index],(char*)"-ip_address")||sc(argv[index],(char*)"-IP")){ serverIP = argv[++index]; got_ip = TRUE; } if(sc(argv[index],(char*)"-command")||sc(argv[index],(char*)"-c")||sc(argv[index],(char*)"-comm")){ snprintf(comm,256,"%s",argv[++index]); got_comm=TRUE; } index++; } if(got_ip==FALSE||got_comm==FALSE){ printf("%s: sends commands to an Agilent scope via ethernet\n",progname); printf("Run using %s [arguments]\n\n",progname); printf("REQUIRED ARGUMENTS:\n"); printf("-ip -ip_address -IP : IP address of scope (eg 128.243.74.232)\n"); printf("-c -command -comm : command or query to send\n\n"); printf("DOCUMENTATION:\n"); printf("http://cp.literature.agilent.com/litweb/pdf/54855-97017.pdf\n"); exit(1); } if (vxi11_open_device(serverIP,clink) != 0) { printf("Quitting...\n"); exit(2); } vxi11_send(clink, comm); if (strstr(comm, "?") != 0) { bytes_returned = vxi11_receive(clink, outputbuf, BUF_LEN); vxi11_close_device(serverIP,clink); if (bytes_returned > 0) { printf("%s",outputbuf); } else if (bytes_returned == -15) { printf("Error: Nothing received after sending scope command %s\n", comm); return(1); } } else { vxi11_close_device(serverIP,clink); } }
int vxi11_open_device(const char *ip, CLINK *clink) { char device[6]; strncpy(device,"inst0",6); return vxi11_open_device(ip, clink, device); }
/* This really is just a wrapper. Only here because folk might be uncomfortable * using commands from the vxi11_vxi11 library directly! */ int lecroy_open(VXI11_CLINK ** clink, const char *ip) { return vxi11_open_device(clink, ip, NULL); }