SDDS ToolKit Programs and Libraries for C and Python
All Classes Files Functions Variables Macros Pages
agilentcomm.cpp File Reference

Detailed Description

Communication interface for Agilent Oscilloscopes via VXI-11 protocol.

This software enables Ethernet-based communication with Agilent oscilloscopes using the VXI-11 protocol. It supports sending commands, queries, and retrieving responses for both control and data acquisition tasks. The tool facilitates integration into automated testing systems.

Usage

./agilentcomm -ip <scope_ip> -c <command> [-h]

Options

Required Description
-ip <scope_ip> Specifies the IP address of the Agilent oscilloscope.
-c <command> The command or query to send to the oscilloscope.
Optional Description
-h Displays help information and usage instructions.
License
This file is distributed under the terms of the Software License Agreement found in the file LICENSE included with this distribution.
Author
Based on software from Steve Sharples of the Univ. of Nottingham. Modified by R. Soliday.

Definition in file agilentcomm.cpp.

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <rpc/rpc.h>
#include <pthread.h>

Go to the source code of this file.

Typedefs

using Device_Link = long
 
using Device_Flags = long
 
using Device_ErrorCode = long
 
using VXI11_CLIENT = CLIENT
 
using VXI11_LINK = Create_LinkResp
 

Functions

bool sc (const char *con, const char *var)
 
int vxi11_open_device (const char *ip, CLINK *clink)
 
int vxi11_open_device (const char *ip, CLINK *clink, const char *device)
 
int vxi11_open_device (const char *ip, CLIENT **client, VXI11_LINK **link, const char *device)
 
int vxi11_open_link (const char *ip, CLIENT **client, VXI11_LINK **link, const char *device)
 
int vxi11_send (CLINK *clink, const char *cmd)
 
int vxi11_send (CLINK *clink, const char *cmd, unsigned long len)
 
int vxi11_send (CLIENT *client, VXI11_LINK *link, const char *cmd)
 
int vxi11_send (CLIENT *client, VXI11_LINK *link, const char *cmd, unsigned long len)
 
int vxi11_close_device (const char *ip, CLINK *clink)
 
int vxi11_close_device (const char *ip, CLIENT *client, VXI11_LINK *link)
 
int vxi11_close_link (const char *ip, CLIENT *client, VXI11_LINK *link)
 
double vxi11_obtain_double_value (CLINK *clink, const char *cmd)
 
double vxi11_obtain_double_value (CLINK *clink, const char *cmd, unsigned long timeout)
 
long vxi11_send_and_receive (CLINK *clink, const char *cmd, char *buf, unsigned long buf_len, unsigned long timeout)
 
long vxi11_receive (CLINK *clink, char *buffer, unsigned long len)
 
long vxi11_receive (CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len, unsigned long timeout)
 
long vxi11_receive (CLINK *clink, char *buffer, unsigned long len, unsigned long timeout)
 
long vxi11_obtain_long_value (CLINK *clink, const char *cmd, unsigned long timeout)
 
long vxi11_obtain_long_value (CLINK *clink, const char *cmd)
 
long vxi11_receive_data_block (CLINK *clink, char *buffer, unsigned long len, unsigned long timeout)
 
enum clnt_stat create_link_1 (Create_LinkParms *argp, Create_LinkResp *clnt_res, CLIENT *clnt)
 
enum clnt_stat device_write_1 (Device_WriteParms *argp, Device_WriteResp *clnt_res, CLIENT *clnt)
 
enum clnt_stat destroy_link_1 (Device_Link *argp, Device_Error *clnt_res, CLIENT *clnt)
 
enum clnt_stat device_read_1 (Device_ReadParms *argp, Device_ReadResp *clnt_res, CLIENT *clnt)
 
bool_t xdr_Create_LinkParms (XDR *xdrs, Create_LinkParms *objp)
 
bool_t xdr_Create_LinkResp (XDR *xdrs, Create_LinkResp *objp)
 
bool_t xdr_Device_ErrorCode (XDR *xdrs, Device_ErrorCode *objp)
 
bool_t xdr_Device_Link (XDR *xdrs, Device_Link *objp)
 
bool_t xdr_Device_WriteParms (XDR *xdrs, Device_WriteParms *objp)
 
bool_t xdr_Device_WriteResp (XDR *xdrs, Device_WriteResp *objp)
 
bool_t xdr_Device_Flags (XDR *xdrs, Device_Flags *objp)
 
bool_t xdr_Device_Error (XDR *xdrs, Device_Error *objp)
 
bool_t xdr_Device_ReadParms (XDR *xdrs, Device_ReadParms *objp)
 
bool_t xdr_Device_ReadResp (XDR *xdrs, Device_ReadResp *objp)
 
int main (int argc, char **argv)
 

Typedef Documentation

◆ Device_ErrorCode

typedef long Device_ErrorCode = long

Definition at line 44 of file agilentcomm.cpp.

◆ Device_Flags

typedef long Device_Flags = long

Definition at line 43 of file agilentcomm.cpp.

◆ Device_Link

typedef long Device_Link = long

Definition at line 42 of file agilentcomm.cpp.

◆ VXI11_CLIENT

using VXI11_CLIENT = CLIENT

Definition at line 105 of file agilentcomm.cpp.

◆ VXI11_LINK

Definition at line 106 of file agilentcomm.cpp.

Function Documentation

◆ create_link_1()

enum clnt_stat create_link_1 ( Create_LinkParms * argp,
Create_LinkResp * clnt_res,
CLIENT * clnt )

Definition at line 345 of file agilentcomm.cpp.

345 {
346 return clnt_call(clnt, CREATE_LINK,
347 reinterpret_cast<xdrproc_t>(xdr_Create_LinkParms), reinterpret_cast<caddr_t>(argp),
348 reinterpret_cast<xdrproc_t>(xdr_Create_LinkResp), reinterpret_cast<caddr_t>(clnt_res),
349 TIMEOUT);
350}

◆ destroy_link_1()

enum clnt_stat destroy_link_1 ( Device_Link * argp,
Device_Error * clnt_res,
CLIENT * clnt )

Definition at line 557 of file agilentcomm.cpp.

557 {
558 return clnt_call(clnt, DESTROY_LINK,
559 reinterpret_cast<xdrproc_t>(xdr_Device_Link), reinterpret_cast<caddr_t>(argp),
560 reinterpret_cast<xdrproc_t>(xdr_Device_Error), reinterpret_cast<caddr_t>(clnt_res),
561 TIMEOUT);
562}

◆ device_read_1()

enum clnt_stat device_read_1 ( Device_ReadParms * argp,
Device_ReadResp * clnt_res,
CLIENT * clnt )

Definition at line 654 of file agilentcomm.cpp.

654 {
655 return clnt_call(clnt, DEVICE_READ,
656 reinterpret_cast<xdrproc_t>(xdr_Device_ReadParms), reinterpret_cast<caddr_t>(argp),
657 reinterpret_cast<xdrproc_t>(xdr_Device_ReadResp), reinterpret_cast<caddr_t>(clnt_res),
658 TIMEOUT);
659}

◆ device_write_1()

enum clnt_stat device_write_1 ( Device_WriteParms * argp,
Device_WriteResp * clnt_res,
CLIENT * clnt )

Definition at line 477 of file agilentcomm.cpp.

477 {
478 return clnt_call(clnt, DEVICE_WRITE,
479 reinterpret_cast<xdrproc_t>(xdr_Device_WriteParms), reinterpret_cast<caddr_t>(argp),
480 reinterpret_cast<xdrproc_t>(xdr_Device_WriteResp), reinterpret_cast<caddr_t>(clnt_res),
481 TIMEOUT);
482}

◆ main()

int main ( int argc,
char ** argv )

Definition at line 172 of file agilentcomm.cpp.

172 {
173 const char *progname = argv[0];
174 const char *serverIP = nullptr;
175 char comm[256] = {0};
176 long bytes_returned = 0;
177 bool got_ip = false;
178 bool got_comm = false;
179 bool got_help = false;
180 int index = 1;
181 CLINK *clink = new CLINK{nullptr, nullptr};
182 char outputbuf[BUF_LEN] = {0};
183
184 // Parse command-line arguments
185 while (index < argc) {
186 if (sc(argv[index], "-ip") || sc(argv[index], "-ip_address") || sc(argv[index], "-IP")) {
187 if (++index < argc) {
188 serverIP = argv[index];
189 got_ip = true;
190 }
191 }
192
193 if (sc(argv[index], "-command") || sc(argv[index], "-c") || sc(argv[index], "-comm")) {
194 if (++index < argc) {
195 std::snprintf(comm, sizeof(comm), "%s", argv[index]);
196 got_comm = true;
197 }
198 }
199
200 // Handle help option
201 if (sc(argv[index], "-h") || sc(argv[index], "-help")) {
202 got_help = true;
203 }
204
205 index++;
206 }
207
208 // Validate required arguments
209 if (!got_ip || !got_comm || got_help) {
210 if (!got_ip || !got_comm) {
211 std::fprintf(stderr, "Error: Missing required arguments.\n\n");
212 }
213 std::printf("Usage: %s [OPTIONS]\n\n", progname);
214 std::printf("Options:\n");
215 std::printf(" -ip, -ip_address, -IP IP address of scope (e.g., 128.243.74.232)\n");
216 std::printf(" -c, -command, -comm Command or query to send\n");
217 std::printf(" -h, -help Display this help message\n\n");
218 std::printf("Documentation:\n");
219 std::printf(" http://cp.literature.agilent.com/litweb/pdf/54855-97017.pdf\n");
220 delete clink;
221 return EXIT_FAILURE;
222 }
223
224 // Open device
225 if (vxi11_open_device(serverIP, clink) != 0) {
226 std::fprintf(stderr, "Error: Failed to open device at IP %s.\n", serverIP);
227 delete clink;
228 return EXIT_FAILURE;
229 }
230
231 // Send command
232 if (vxi11_send(clink, comm) != 0) {
233 std::fprintf(stderr, "Error: Failed to send command '%s' to device.\n", comm);
234 vxi11_close_device(serverIP, clink);
235 delete clink;
236 return EXIT_FAILURE;
237 }
238
239 // Check if it's a query
240 if (std::strchr(comm, '?') != nullptr) {
241 bytes_returned = vxi11_receive(clink, outputbuf, BUF_LEN);
242 vxi11_close_device(serverIP, clink);
243
244 if (bytes_returned > 0) {
245 std::printf("%s\n", outputbuf);
246 } else if (bytes_returned == -VXI11_NULL_READ_RESP) {
247 std::fprintf(stderr, "Error: Nothing received after sending scope command '%s'.\n", comm);
248 delete clink;
249 return EXIT_FAILURE;
250 } else {
251 std::fprintf(stderr, "Error: Failed to receive response for command '%s'.\n", comm);
252 delete clink;
253 return EXIT_FAILURE;
254 }
255 } else {
256 vxi11_close_device(serverIP, clink);
257 }
258
259 delete clink;
260 return EXIT_SUCCESS;
261}

◆ sc()

bool sc ( const char * con,
const char * var )

Definition at line 264 of file agilentcomm.cpp.

264 {
265 return std::strcmp(con, var) == 0;
266}

◆ vxi11_close_device() [1/2]

int vxi11_close_device ( const char * ip,
CLIENT * client,
VXI11_LINK * link )

Definition at line 536 of file agilentcomm.cpp.

536 {
537 int ret = vxi11_close_link(ip, client, link);
538 clnt_destroy(client);
539 return ret;
540}

◆ vxi11_close_device() [2/2]

int vxi11_close_device ( const char * ip,
CLINK * clink )

Definition at line 510 of file agilentcomm.cpp.

510 {
511 int ret;
512 int device_no = -1;
513
514 // Identify the device number based on IP
515 for (int l = 0; l < VXI11_MAX_CLIENTS; l++) {
516 if (std::strcmp(ip, VXI11_IP_ADDRESS[l]) == 0) {
517 device_no = l;
518 break;
519 }
520 }
521
522 if (device_no == -1) {
523 std::fprintf(stderr, "vxi11_close_device: error: No record of opening device with IP address %s.\n", ip);
524 ret = -4;
525 } else {
526 if (VXI11_LINK_COUNT[device_no] > 1) {
527 ret = vxi11_close_link(ip, clink->client, clink->link);
528 VXI11_LINK_COUNT[device_no]--;
529 } else {
530 ret = vxi11_close_device(ip, clink->client, clink->link);
531 }
532 }
533 return ret;
534}

◆ vxi11_close_link()

int vxi11_close_link ( const char * ip,
CLIENT * client,
VXI11_LINK * link )

Definition at line 542 of file agilentcomm.cpp.

542 {
543 Device_Error dev_error{};
544
545 if (destroy_link_1(&link->lid, &dev_error, client) != RPC_SUCCESS) {
546#ifdef __APPLE__
547 clnt_perror(client, reinterpret_cast<char *>(ip));
548#else
549 clnt_perror(client, ip);
550#endif
551 return -1;
552 }
553
554 return 0;
555}

◆ vxi11_obtain_double_value() [1/2]

double vxi11_obtain_double_value ( CLINK * clink,
const char * cmd )

Definition at line 568 of file agilentcomm.cpp.

568 {
569 return vxi11_obtain_double_value(clink, cmd, VXI11_READ_TIMEOUT);
570}

◆ vxi11_obtain_double_value() [2/2]

double vxi11_obtain_double_value ( CLINK * clink,
const char * cmd,
unsigned long timeout )

Definition at line 572 of file agilentcomm.cpp.

572 {
573 char buf[50] = {0}; // 50=arbitrary length... more than enough for one number in ascii
574 if (vxi11_send_and_receive(clink, cmd, buf, sizeof(buf), timeout) != 0) {
575 std::fprintf(stderr, "Warning: Failed to obtain double value. Returning 0.0.\n");
576 return 0.0;
577 }
578 return std::strtod(buf, nullptr);
579}

◆ vxi11_obtain_long_value() [1/2]

long vxi11_obtain_long_value ( CLINK * clink,
const char * cmd )

Definition at line 747 of file agilentcomm.cpp.

747 {
748 return vxi11_obtain_long_value(clink, cmd, VXI11_READ_TIMEOUT);
749}

◆ vxi11_obtain_long_value() [2/2]

long vxi11_obtain_long_value ( CLINK * clink,
const char * cmd,
unsigned long timeout )

Definition at line 737 of file agilentcomm.cpp.

737 {
738 char buf[50] = {0}; // 50=arbitrary length... more than enough for one number in ascii
739 if (vxi11_send_and_receive(clink, cmd, buf, sizeof(buf), timeout) != 0) {
740 std::fprintf(stderr, "Warning: Failed to obtain long value. Returning 0.\n");
741 return 0;
742 }
743 return std::strtol(buf, nullptr, 10);
744}

◆ vxi11_open_device() [1/3]

int vxi11_open_device ( const char * ip,
CLIENT ** client,
VXI11_LINK ** link,
const char * device )

Definition at line 273 of file agilentcomm.cpp.

273 {
274#ifdef __APPLE__
275 *client = clnt_create(reinterpret_cast<char *>(ip), DEVICE_CORE, DEVICE_CORE_VERSION, "tcp");
276#else
277 *client = clnt_create(ip, DEVICE_CORE, DEVICE_CORE_VERSION, "tcp");
278#endif
279
280 if (*client == nullptr) {
281#ifdef __APPLE__
282 clnt_pcreateerror(reinterpret_cast<char *>(ip));
283#else
284 clnt_pcreateerror(ip);
285#endif
286 return -1;
287 }
288
289 return vxi11_open_link(ip, client, link, device);
290}

◆ vxi11_open_device() [2/3]

int vxi11_open_device ( const char * ip,
CLINK * clink )

Definition at line 268 of file agilentcomm.cpp.

268 {
269 const char device[] = "inst0";
270 return vxi11_open_device(ip, clink, device);
271}

◆ vxi11_open_device() [3/3]

int vxi11_open_device ( const char * ip,
CLINK * clink,
const char * device )

Definition at line 292 of file agilentcomm.cpp.

292 {
293 int ret;
294 int device_no = -1;
295
296 for (int l = 0; l < VXI11_MAX_CLIENTS; l++) {
297 if (std::strcmp(ip, VXI11_IP_ADDRESS[l]) == 0) {
298 device_no = l;
299 break;
300 }
301 }
302
303 if (device_no < 0) {
304 if (VXI11_DEVICE_NO >= VXI11_MAX_CLIENTS) {
305 std::fprintf(stderr, "Error: Maximum of %d clients allowed.\n", VXI11_MAX_CLIENTS);
306 ret = -VXI11_MAX_CLIENTS;
307 } else {
308 ret = vxi11_open_device(ip, &(clink->client), &(clink->link), device);
309 std::strncpy(VXI11_IP_ADDRESS[VXI11_DEVICE_NO], ip, sizeof(VXI11_IP_ADDRESS[VXI11_DEVICE_NO]) - 1);
310 VXI11_IP_ADDRESS[VXI11_DEVICE_NO][sizeof(VXI11_IP_ADDRESS[VXI11_DEVICE_NO]) - 1] = '\0';
311 VXI11_CLIENT_ADDRESS[VXI11_DEVICE_NO] = clink->client;
312 VXI11_LINK_COUNT[VXI11_DEVICE_NO] = 1;
313 VXI11_DEVICE_NO++;
314 }
315 } else {
316 clink->client = VXI11_CLIENT_ADDRESS[device_no];
317 ret = vxi11_open_link(ip, &(clink->client), &(clink->link), device);
318 VXI11_LINK_COUNT[device_no]++;
319 }
320 return ret;
321}

◆ vxi11_open_link()

int vxi11_open_link ( const char * ip,
CLIENT ** client,
VXI11_LINK ** link,
const char * device )

Definition at line 323 of file agilentcomm.cpp.

323 {
324 Create_LinkParms link_parms;
325
326 // Set link parameters
327 link_parms.clientId = reinterpret_cast<long>(*client);
328 link_parms.lockDevice = false;
329 link_parms.lock_timeout = VXI11_DEFAULT_TIMEOUT;
330 link_parms.device = const_cast<char *>(device);
331
332 *link = new Create_LinkResp();
333
334 if (create_link_1(&link_parms, *link, *client) != RPC_SUCCESS) {
335#ifdef __APPLE__
336 clnt_perror(*client, reinterpret_cast<char *>(ip));
337#else
338 clnt_perror(*client, ip);
339#endif
340 return -2;
341 }
342 return 0;
343}

◆ vxi11_receive() [1/3]

long vxi11_receive ( CLIENT * client,
VXI11_LINK * link,
char * buffer,
unsigned long len,
unsigned long timeout )

Definition at line 608 of file agilentcomm.cpp.

608 {
609 Device_ReadParms read_parms;
610 Device_ReadResp read_resp{};
611 long curr_pos = 0;
612
613 read_parms.lid = link->lid;
614 read_parms.requestSize = len;
615 read_parms.io_timeout = timeout; // in ms
616 read_parms.lock_timeout = timeout; // in ms
617 read_parms.flags = 0;
618 read_parms.termChar = 0;
619
620 while (true) {
621 read_resp = Device_ReadResp{};
622 read_resp.data.data_val = buffer + curr_pos;
623 read_parms.requestSize = len - curr_pos; // Never request more total data than originally specified in len
624
625 if (device_read_1(&read_parms, &read_resp, client) != RPC_SUCCESS) {
626 return -VXI11_NULL_READ_RESP; // No data to read
627 }
628 if (read_resp.error != 0) {
629 std::fprintf(stderr, "vxi11_user: read error: %ld\n", read_resp.error);
630 return -(read_resp.error);
631 }
632
633 if ((unsigned long)(curr_pos + read_resp.data.data_len) <= len) {
634 curr_pos += read_resp.data.data_len;
635 }
636 if ((read_resp.reason & RCV_END_BIT) || (read_resp.reason & RCV_CHR_BIT)) {
637 break;
638 } else if ((unsigned long)curr_pos == len) {
639 std::fprintf(stderr, "vxi11_user: read error: Buffer too small. Read %ld bytes without hitting terminator.\n", curr_pos);
640 return -100;
641 }
642 }
643 return curr_pos; // Actual number of bytes received
644}

◆ vxi11_receive() [2/3]

long vxi11_receive ( CLINK * clink,
char * buffer,
unsigned long len )

Definition at line 646 of file agilentcomm.cpp.

646 {
647 return vxi11_receive(clink, buffer, len, VXI11_READ_TIMEOUT);
648}

◆ vxi11_receive() [3/3]

long vxi11_receive ( CLINK * clink,
char * buffer,
unsigned long len,
unsigned long timeout )

Definition at line 650 of file agilentcomm.cpp.

650 {
651 return vxi11_receive(clink->client, clink->link, buffer, len, timeout);
652}

◆ vxi11_receive_data_block()

long vxi11_receive_data_block ( CLINK * clink,
char * buffer,
unsigned long len,
unsigned long timeout )

Definition at line 751 of file agilentcomm.cpp.

751 {
752 // Assuming the maximum length of the header is 11 (#9 + 9 digits)
753 unsigned long necessary_buffer_size = len + 12;
754 char *in_buffer = new char[necessary_buffer_size];
755 long ret = vxi11_receive(clink, in_buffer, necessary_buffer_size, timeout);
756 if (ret < 0) {
757 delete[] in_buffer;
758 return ret;
759 }
760 if (in_buffer[0] != '#') {
761 std::fprintf(stderr, "vxi11_user: data block error: Data block does not begin with '#'.\n");
762 std::fprintf(stderr, "First 20 characters received were: '");
763 for (size_t l = 0; l < 20 && l < (size_t)necessary_buffer_size; l++) {
764 std::fprintf(stderr, "%c", in_buffer[l]);
765 }
766 std::fprintf(stderr, "'\n");
767 delete[] in_buffer;
768 return -3;
769 }
770
771 // First, find out how many digits
772 int ndigits = 0;
773 sscanf(in_buffer, "#%1d", &ndigits);
774
775 // Some instruments, if there is a problem acquiring the data, return only "#0"
776 if (ndigits > 0) {
777 // Convert the next <ndigits> bytes into an unsigned long
778 char scan_cmd[20];
779 std::snprintf(scan_cmd, sizeof(scan_cmd), "#%%1d%%%dlu", ndigits);
780 unsigned long returned_bytes = 0;
781 sscanf(in_buffer, scan_cmd, &ndigits, &returned_bytes);
782 std::memcpy(buffer, in_buffer + (ndigits + 2), returned_bytes);
783 delete[] in_buffer;
784 return static_cast<long>(returned_bytes);
785 } else {
786 delete[] in_buffer;
787 return 0;
788 }
789}

◆ vxi11_send() [1/4]

int vxi11_send ( CLIENT * client,
VXI11_LINK * link,
const char * cmd )

Definition at line 434 of file agilentcomm.cpp.

434 {
435 return vxi11_send(client, link, cmd, std::strlen(cmd));
436}

◆ vxi11_send() [2/4]

int vxi11_send ( CLIENT * client,
VXI11_LINK * link,
const char * cmd,
unsigned long len )

Definition at line 438 of file agilentcomm.cpp.

438 {
439 Device_WriteParms write_parms;
440 int bytes_left = static_cast<int>(len);
441 char *send_cmd = new char[len];
442 std::memcpy(send_cmd, cmd, len);
443
444 write_parms.lid = link->lid;
445 write_parms.io_timeout = VXI11_DEFAULT_TIMEOUT;
446 write_parms.lock_timeout = VXI11_DEFAULT_TIMEOUT;
447
448 // We can only write (link->maxRecvSize) bytes at a time
449 while (bytes_left > 0) {
450 Device_WriteResp write_resp{};
451
452 if (static_cast<unsigned int>(bytes_left) <= link->maxRecvSize) {
453 write_parms.flags = 8;
454 write_parms.data.data_len = bytes_left;
455 } else {
456 write_parms.flags = 0;
457 write_parms.data.data_len = (link->maxRecvSize > 0) ? link->maxRecvSize : 4096;
458 }
459 write_parms.data.data_val = send_cmd + (len - bytes_left);
460
461 if (device_write_1(&write_parms, &write_resp, client) != RPC_SUCCESS) {
462 delete[] send_cmd;
463 return -VXI11_NULL_WRITE_RESP;
464 }
465 if (write_resp.error != 0) {
466 std::fprintf(stderr, "vxi11_user: write error: %ld\n", write_resp.error);
467 delete[] send_cmd;
468 return -(write_resp.error);
469 }
470 bytes_left -= write_resp.size;
471 }
472
473 delete[] send_cmd;
474 return 0;
475}

◆ vxi11_send() [3/4]

int vxi11_send ( CLINK * clink,
const char * cmd )

Definition at line 426 of file agilentcomm.cpp.

426 {
427 return vxi11_send(clink, cmd, std::strlen(cmd));
428}

◆ vxi11_send() [4/4]

int vxi11_send ( CLINK * clink,
const char * cmd,
unsigned long len )

Definition at line 430 of file agilentcomm.cpp.

430 {
431 return vxi11_send(clink->client, clink->link, cmd, len);
432}

◆ vxi11_send_and_receive()

long vxi11_send_and_receive ( CLINK * clink,
const char * cmd,
char * buf,
unsigned long buf_len,
unsigned long timeout )

Definition at line 581 of file agilentcomm.cpp.

581 {
582 int ret;
583 long bytes_returned;
584 do {
585 ret = vxi11_send(clink, cmd);
586 if (ret != 0) {
587 if (ret != -VXI11_NULL_WRITE_RESP) {
588 std::fprintf(stderr, "Error: vxi11_send_and_receive: Could not send command '%s'. Return code: %d.\n", cmd, ret);
589 return -1;
590 } else {
591 std::printf("(Info: VXI11_NULL_WRITE_RESP in vxi11_send_and_receive, resending query)\n");
592 }
593 }
594
595 bytes_returned = vxi11_receive(clink, buf, buf_len, timeout);
596 if (bytes_returned <= 0) {
597 if (bytes_returned > -VXI11_NULL_READ_RESP) {
598 std::fprintf(stderr, "Error: vxi11_send_and_receive: Problem reading reply. Return code: %ld.\n", bytes_returned);
599 return -2;
600 } else {
601 std::printf("(Info: VXI11_NULL_READ_RESP in vxi11_send_and_receive, resending query)\n");
602 }
603 }
604 } while (bytes_returned == -VXI11_NULL_READ_RESP || ret == -VXI11_NULL_WRITE_RESP);
605 return 0;
606}

◆ xdr_Create_LinkParms()

bool_t xdr_Create_LinkParms ( XDR * xdrs,
Create_LinkParms * objp )

Definition at line 352 of file agilentcomm.cpp.

352 {
353#if defined(SOLARIS) && !defined(_LP64)
354 long *buf;
355#else
356 int32_t *buf;
357#endif
358
359 if (xdrs->x_op == XDR_ENCODE) {
360 buf = reinterpret_cast<int32_t *>(XDR_INLINE(xdrs, 3 * BYTES_PER_XDR_UNIT));
361 if (buf == nullptr) {
362 if (!xdr_long(xdrs, &objp->clientId))
363 return FALSE;
364 if (!xdr_bool(xdrs, &objp->lockDevice))
365 return FALSE;
366 if (!xdr_u_long(xdrs, &objp->lock_timeout))
367 return FALSE;
368 } else {
369 IXDR_PUT_INT32(buf, objp->clientId);
370 IXDR_PUT_BOOL(buf, objp->lockDevice);
371 IXDR_PUT_U_INT32(buf, objp->lock_timeout);
372 }
373 if (!xdr_string(xdrs, &objp->device, ~0))
374 return FALSE;
375 return TRUE;
376 } else if (xdrs->x_op == XDR_DECODE) {
377 buf = reinterpret_cast<int32_t *>(XDR_INLINE(xdrs, 3 * BYTES_PER_XDR_UNIT));
378 if (buf == nullptr) {
379 if (!xdr_long(xdrs, &objp->clientId))
380 return FALSE;
381 if (!xdr_bool(xdrs, &objp->lockDevice))
382 return FALSE;
383 if (!xdr_u_long(xdrs, &objp->lock_timeout))
384 return FALSE;
385 } else {
386 objp->clientId = IXDR_GET_INT32(buf);
387 objp->lockDevice = IXDR_GET_BOOL(buf);
388 objp->lock_timeout = IXDR_GET_U_INT32(buf);
389 }
390 if (!xdr_string(xdrs, &objp->device, ~0))
391 return FALSE;
392 return TRUE;
393 }
394
395 if (!xdr_long(xdrs, &objp->clientId))
396 return FALSE;
397 if (!xdr_bool(xdrs, &objp->lockDevice))
398 return FALSE;
399 if (!xdr_u_long(xdrs, &objp->lock_timeout))
400 return FALSE;
401 if (!xdr_string(xdrs, &objp->device, ~0))
402 return FALSE;
403 return TRUE;
404}

◆ xdr_Create_LinkResp()

bool_t xdr_Create_LinkResp ( XDR * xdrs,
Create_LinkResp * objp )

Definition at line 406 of file agilentcomm.cpp.

406 {
407 if (!xdr_Device_ErrorCode(xdrs, &objp->error))
408 return FALSE;
409 if (!xdr_Device_Link(xdrs, &objp->lid))
410 return FALSE;
411 if (!xdr_u_short(xdrs, &objp->abortPort))
412 return FALSE;
413 if (!xdr_u_long(xdrs, &objp->maxRecvSize))
414 return FALSE;
415 return TRUE;
416}

◆ xdr_Device_Error()

bool_t xdr_Device_Error ( XDR * xdrs,
Device_Error * objp )

Definition at line 564 of file agilentcomm.cpp.

564 {
565 return xdr_Device_ErrorCode(xdrs, &objp->error);
566}

◆ xdr_Device_ErrorCode()

bool_t xdr_Device_ErrorCode ( XDR * xdrs,
Device_ErrorCode * objp )

Definition at line 418 of file agilentcomm.cpp.

418 {
419 return xdr_long(xdrs, objp);
420}

◆ xdr_Device_Flags()

bool_t xdr_Device_Flags ( XDR * xdrs,
Device_Flags * objp )

Definition at line 506 of file agilentcomm.cpp.

506 {
507 return xdr_long(xdrs, objp);
508}

◆ xdr_Device_Link()

bool_t xdr_Device_Link ( XDR * xdrs,
Device_Link * objp )

Definition at line 422 of file agilentcomm.cpp.

422 {
423 return xdr_long(xdrs, objp);
424}

◆ xdr_Device_ReadParms()

bool_t xdr_Device_ReadParms ( XDR * xdrs,
Device_ReadParms * objp )

Definition at line 661 of file agilentcomm.cpp.

661 {
662#if defined(SOLARIS) && !defined(_LP64)
663 long *buf;
664#else
665 int32_t *buf;
666#endif
667
668 if (xdrs->x_op == XDR_ENCODE) {
669 if (!xdr_Device_Link(xdrs, &objp->lid))
670 return FALSE;
671 buf = reinterpret_cast<int32_t *>(XDR_INLINE(xdrs, 3 * BYTES_PER_XDR_UNIT));
672 if (buf == nullptr) {
673 if (!xdr_u_long(xdrs, &objp->requestSize))
674 return FALSE;
675 if (!xdr_u_long(xdrs, &objp->io_timeout))
676 return FALSE;
677 if (!xdr_u_long(xdrs, &objp->lock_timeout))
678 return FALSE;
679 } else {
680 IXDR_PUT_U_INT32(buf, objp->requestSize);
681 IXDR_PUT_U_INT32(buf, objp->io_timeout);
682 IXDR_PUT_U_INT32(buf, objp->lock_timeout);
683 }
684 if (!xdr_Device_Flags(xdrs, &objp->flags))
685 return FALSE;
686 if (!xdr_char(xdrs, &objp->termChar))
687 return FALSE;
688 return TRUE;
689 } else if (xdrs->x_op == XDR_DECODE) {
690 if (!xdr_Device_Link(xdrs, &objp->lid))
691 return FALSE;
692 buf = reinterpret_cast<int32_t *>(XDR_INLINE(xdrs, 3 * BYTES_PER_XDR_UNIT));
693 if (buf == nullptr) {
694 if (!xdr_u_long(xdrs, &objp->requestSize))
695 return FALSE;
696 if (!xdr_u_long(xdrs, &objp->io_timeout))
697 return FALSE;
698 if (!xdr_u_long(xdrs, &objp->lock_timeout))
699 return FALSE;
700 } else {
701 objp->requestSize = IXDR_GET_U_INT32(buf);
702 objp->io_timeout = IXDR_GET_U_INT32(buf);
703 objp->lock_timeout = IXDR_GET_U_INT32(buf);
704 }
705 if (!xdr_Device_Flags(xdrs, &objp->flags))
706 return FALSE;
707 if (!xdr_char(xdrs, &objp->termChar))
708 return FALSE;
709 return TRUE;
710 }
711
712 if (!xdr_Device_Link(xdrs, &objp->lid))
713 return FALSE;
714 if (!xdr_u_long(xdrs, &objp->requestSize))
715 return FALSE;
716 if (!xdr_u_long(xdrs, &objp->io_timeout))
717 return FALSE;
718 if (!xdr_u_long(xdrs, &objp->lock_timeout))
719 return FALSE;
720 if (!xdr_Device_Flags(xdrs, &objp->flags))
721 return FALSE;
722 if (!xdr_char(xdrs, &objp->termChar))
723 return FALSE;
724 return TRUE;
725}

◆ xdr_Device_ReadResp()

bool_t xdr_Device_ReadResp ( XDR * xdrs,
Device_ReadResp * objp )

Definition at line 727 of file agilentcomm.cpp.

727 {
728 if (!xdr_Device_ErrorCode(xdrs, &objp->error))
729 return FALSE;
730 if (!xdr_long(xdrs, &objp->reason))
731 return FALSE;
732 if (!xdr_bytes(xdrs, reinterpret_cast<char **>(&objp->data.data_val), reinterpret_cast<u_int *>(&objp->data.data_len), ~0))
733 return FALSE;
734 return TRUE;
735}

◆ xdr_Device_WriteParms()

bool_t xdr_Device_WriteParms ( XDR * xdrs,
Device_WriteParms * objp )

Definition at line 484 of file agilentcomm.cpp.

484 {
485 if (!xdr_Device_Link(xdrs, &objp->lid))
486 return FALSE;
487 if (!xdr_u_long(xdrs, &objp->io_timeout))
488 return FALSE;
489 if (!xdr_u_long(xdrs, &objp->lock_timeout))
490 return FALSE;
491 if (!xdr_Device_Flags(xdrs, &objp->flags))
492 return FALSE;
493 if (!xdr_bytes(xdrs, reinterpret_cast<char **>(&objp->data.data_val), reinterpret_cast<u_int *>(&objp->data.data_len), ~0))
494 return FALSE;
495 return TRUE;
496}

◆ xdr_Device_WriteResp()

bool_t xdr_Device_WriteResp ( XDR * xdrs,
Device_WriteResp * objp )

Definition at line 498 of file agilentcomm.cpp.

498 {
499 if (!xdr_Device_ErrorCode(xdrs, &objp->error))
500 return FALSE;
501 if (!xdr_u_long(xdrs, &objp->size))
502 return FALSE;
503 return TRUE;
504}