summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libvxi11client/perlbits/Client.pm21
-rw-r--r--libvxi11client/perlbits/Client.xs9
-rw-r--r--libvxi11client/perlbits/VXI11-Client.t4
-rw-r--r--vxi11_server.c10
4 files changed, 35 insertions, 9 deletions
diff --git a/libvxi11client/perlbits/Client.pm b/libvxi11client/perlbits/Client.pm
index 605d864..df58e34 100644
--- a/libvxi11client/perlbits/Client.pm
+++ b/libvxi11client/perlbits/Client.pm
@@ -75,6 +75,27 @@ sub vxi_read {
return ($bytes, $string, $reason);
}
+sub vxi_docmd {
+ my $self = shift;
+ my $cmd = shift;
+ my %args = (
+ datain => "",
+ datainlen => -1,
+ dataoutbufferlen => 256,
+ waitlock => 0,
+ autochomp => 1,
+ @_
+ );
+
+ my ($ret, $dataout, $dataoutlen) = vxi_docmd_long($self, $args{datain}, $args{datainlen}, $args{dataoutbufferlen}, $args{waitlock});
+
+ if ($args{autochomp}) {
+ chomp ($dataout);
+ }
+
+ return ($ret, $dataout);
+}
+
1;
__END__
# Below is stub documentation for your module. You'd better edit it!
diff --git a/libvxi11client/perlbits/Client.xs b/libvxi11client/perlbits/Client.xs
index 0de2df3..48571d9 100644
--- a/libvxi11client/perlbits/Client.xs
+++ b/libvxi11client/perlbits/Client.xs
@@ -68,12 +68,17 @@ vxi_destroy_intr_chan(context)
RETVAL
int
-vxi_docmd(context, cmd, waitforlock = 0)
+vxi_docmd_long(context, datain, datainlen, OUTLIST dataout, outbufferlen, OUTLIST dataoutlen, cmd, waitforlock = 0)
VXI11::Client context
+ char* datain
+ int datainlen
+ char* dataout
+ int outbufferlen
+ int dataoutlen
unsigned long cmd
bool waitforlock
CODE:
- RETVAL = vxi11_docmd(context, cmd, waitforlock);
+ RETVAL = vxi11_docmd(context, datain, datainlen, dataout, outbufferlen, &dataoutlen, cmd, waitforlock);
OUTPUT:
RETVAL
diff --git a/libvxi11client/perlbits/VXI11-Client.t b/libvxi11client/perlbits/VXI11-Client.t
index affa622..8a09a55 100644
--- a/libvxi11client/perlbits/VXI11-Client.t
+++ b/libvxi11client/perlbits/VXI11-Client.t
@@ -18,7 +18,8 @@ BEGIN { use_ok('VXI11::Client') };
&VXI11::Client::vxi_startinterruptserver();
-my $instr = &VXI11::Client::vxi_open("192.168.0.62", 0);
+my $address = "roi";
+my $instr = &VXI11::Client::vxi_open($address, 0);
is($instr->vxi_lock(0), 1, "Lock");
ok($instr->vxi_write("*idn?") > 0, "Write");
@@ -40,6 +41,7 @@ is($instr->vxi_clear(), 1, "Clear");
is($instr->vxi_trigger(), 1, "Trigger");
is($instr->vxi_local(), 1, "Local");
is($instr->vxi_remote(), 1, "Remote");
+#ok($instr->vxi_docmd(1) < 1, "docmd"); #this should fail on the bb server
is($instr->vxi_unlock(), 1, "Unlock");
is($instr->vxi_close(), 1, "Close");
diff --git a/vxi11_server.c b/vxi11_server.c
index cb7f600..ae8317f 100644
--- a/vxi11_server.c
+++ b/vxi11_server.c
@@ -204,18 +204,16 @@ device_write_1_svc(Device_WriteParms *argp, struct svc_req *rqstp) {
result.error = ERR_IOTIMEOUT;
else {
touchlink(argp->lid);
- argp->data.data_val = realloc(argp->data.data_val, argp->data.data_len + 1); // realloc to get an extra byte
- argp->data.data_val[argp->data.data_len] = '\0'; //
+ gchar* str = g_strndup(argp->data.data_val, argp->data.data_len);
#ifdef DEBUG
int n;
- char *str = argp->data.data_val;
for (n = 0; str[n] != '\0'; n++)
printf("%02x ", (unsigned char) str[n]);
printf("\n");
- printf("got <<%s>> (reported length %d)on link %d.\n", argp->data.data_val, (int) argp->data.data_len,
- (int) argp->lid);
+ printf("got <<%s>> (reported length %d)on link %d.\n", str, (int) argp->data.data_len, (int) argp->lid);
#endif
- Parser_main(argp->data.data_val, 0, GPIB_and_VXI_start_query_response, NULL);
+ Parser_main(str, 0, GPIB_and_VXI_start_query_response, NULL);
+ g_free(str);
result.size = argp->data.data_len;
}