diff options
-rw-r--r-- | libvxi11client/libvxi11client.c | 13 | ||||
-rw-r--r-- | libvxi11client/perlbits/Client.pm | 2 | ||||
-rw-r--r-- | libvxi11client/perlbits/Client.xs | 20 | ||||
-rw-r--r-- | libvxi11client/perlbits/VXI11-Client.t | 5 | ||||
-rw-r--r-- | libvxi11client/perlbits/testscript.pl | 4 | ||||
-rw-r--r-- | libvxi11client/perlbits/typemap | 2 |
6 files changed, 31 insertions, 15 deletions
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c index 5d09786..66bb020 100644 --- a/libvxi11client/libvxi11client.c +++ b/libvxi11client/libvxi11client.c @@ -16,7 +16,6 @@ /** * This is a thin wrapper around the rpcgen generated code to give it a simpler interface. - * Only one server with a single link is supported. */ #define FLAG_TERMCHRSET (1 << 7) @@ -154,6 +153,7 @@ int vxi11_open(VXI11Context* context, char* address, char* device) { /** * read the status byte of the connected server + * returns -1 */ int vxi11_readstatusbyte(VXI11Context* context, bool waitforlock) { @@ -165,11 +165,12 @@ int vxi11_readstatusbyte(VXI11Context* context, bool waitforlock) { Device_ReadStbResp* resp = device_readstb_1(¶ms, context->clnt); if (resp != NULL && resp->error == 0) - return resp->stb; + return resp->stb | (1 << 8); // this sets a bit above the byte so that we can tell whether there was a state issue + // or if the instrument returned 0 else if (resp == NULL) return 0; else - return -1; + return -(resp->error); } /** @@ -192,7 +193,7 @@ int vxi11_write(VXI11Context* context, char* data, int len, bool waitlock, bool else if (resp == NULL) return 0; else - return -1; + return -(resp->error); } /** @@ -226,11 +227,11 @@ int vxi11_read(VXI11Context* context, char* buffer, unsigned int bufferlen, bool else if (resp == NULL) return 0; else - return -1; + return -(resp->error); } /** - * + * call docmd with the specified command */ int vxi11_docmd(VXI11Context* context, unsigned long cmd, bool waitforlock) { diff --git a/libvxi11client/perlbits/Client.pm b/libvxi11client/perlbits/Client.pm index c92d613..9b8fdb2 100644 --- a/libvxi11client/perlbits/Client.pm +++ b/libvxi11client/perlbits/Client.pm @@ -56,7 +56,7 @@ VXI11::Client - Perl extension for interfacing with VXI-11 networked instruments my ($bytes, $buff, $reason) = $instr->vxi_read(256, 0, 0, 0); print "got " . $bytes . ";" . $buff . "\n"; - $instr->vxi_readstatusbyte(0); + my ($error, $statusbyte) = $instr->vxi_readstatusbyte(0); $instr->vxi_create_intr_chan(); $instr->vxi_enable_srq(1, "myhandle"); vxi_wait_for_interrupt(); diff --git a/libvxi11client/perlbits/Client.xs b/libvxi11client/perlbits/Client.xs index d471fda..b09ee0a 100644 --- a/libvxi11client/perlbits/Client.xs +++ b/libvxi11client/perlbits/Client.xs @@ -136,14 +136,22 @@ vxi_read(context, OUTLIST bytesread, OUTLIST buffer, bufferlen, waitlock, termch buffer = malloc(bufferlen + 1); bytesread = vxi11_read(context, buffer, bufferlen, waitlock, termchrset, termchr, reason); -int -vxi_readstatusbyte(context, waitforlock) +void +vxi_readstatusbyte(context, waitforlock, OUTLIST error, OUTLIST statusbyte) VXI11::Client context bool waitforlock - CODE: - RETVAL = vxi11_readstatusbyte(context, waitforlock); - OUTPUT: - RETVAL + int* error + int* statusbyte + CODE: + int ret = vxi11_readstatusbyte(context, waitforlock); + if(ret > 0){ + *statusbyte = ret & 0xff; + *error = 0; + } + else { + *statusbyte = 0; + *error = ret; + } int vxi_remote(context, waitforlock) diff --git a/libvxi11client/perlbits/VXI11-Client.t b/libvxi11client/perlbits/VXI11-Client.t index 3334d3c..7054d39 100644 --- a/libvxi11client/perlbits/VXI11-Client.t +++ b/libvxi11client/perlbits/VXI11-Client.t @@ -27,7 +27,10 @@ my ($bytes, $buff, $reason) = $instr->vxi_read(256, 0, 0, 0); print "got " . $bytes . ";" . $buff . "\n"; ok($bytes > 0, "Read"); -ok($instr->vxi_readstatusbyte(0) >= 0 , "Read status byte"); + +my ($error, $statusbyte) = $instr->vxi_readstatusbyte(0); +ok($error == 0 , "Read status byte"); + is($instr->vxi_create_intr_chan(), 1, "Create intr channel"); is($instr->vxi_enable_srq(1, "myhandle"), 1, "Enable interrupts"); is(&VXI11::Client::vxi_wait_for_interrupt, "myhandle", "Wait for interrupt"); diff --git a/libvxi11client/perlbits/testscript.pl b/libvxi11client/perlbits/testscript.pl index f588aaf..45a3d01 100644 --- a/libvxi11client/perlbits/testscript.pl +++ b/libvxi11client/perlbits/testscript.pl @@ -14,7 +14,9 @@ $instr->vxi_write("*IDN?", -1, 0, 0); my ($bytes, $buff, $reason) = $instr->vxi_read(256, 0, 0, 0); print "got " . $bytes . ";" . $buff . "\n"; -$instr->vxi_readstatusbyte(0); +my ($error, $statusbyte) = $instr->vxi_readstatusbyte(0); +printf "status byte is " . $statusbyte . "\n"; + $instr->vxi_create_intr_chan(); $instr->vxi_enable_srq(1, "myhandle"); vxi_wait_for_interrupt(); diff --git a/libvxi11client/perlbits/typemap b/libvxi11client/perlbits/typemap index 3b9a362..3817e78 100644 --- a/libvxi11client/perlbits/typemap +++ b/libvxi11client/perlbits/typemap @@ -1,3 +1,5 @@ VXI11Context * T_PTROBJ VXI11::Client T_PTROBJ unsigned int * T_IV +int * T_IV + |