summaryrefslogtreecommitdiff
path: root/libvxi11client
diff options
context:
space:
mode:
Diffstat (limited to 'libvxi11client')
-rw-r--r--libvxi11client/libvxi11client.c7
-rw-r--r--libvxi11client/libvxi11client.h2
-rw-r--r--libvxi11client/perlbits/Client.xs2
-rw-r--r--libvxi11client/perlbits/VXI11-Client.t2
-rw-r--r--libvxi11client/perlbits/perlglue.c2
5 files changed, 8 insertions, 7 deletions
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c
index 4b17532..a6a5dd2 100644
--- a/libvxi11client/libvxi11client.c
+++ b/libvxi11client/libvxi11client.c
@@ -171,16 +171,17 @@ int vxi11_readstatusbyte(VXI11Context* context, bool waitforlock) {
}
/**
- * write to the connected device
+ * write to the connected device. If len is less than 0 the length will be calculated with strlen
+ * **only safe for standard terminated strings**
*/
-int vxi11_write(VXI11Context* context, char* data, unsigned int len, bool waitlock, bool end) {
+int vxi11_write(VXI11Context* context, char* data, int len, bool waitlock, bool end) {
if (context->clnt == NULL)
return 0;
Device_WriteParms params = { .lid = context->devicelink, .io_timeout = VXI11_DEFAULT_TIMEOUT, .lock_timeout =
VXI11_DEFAULT_TIMEOUT, .flags = vxi11_generateflags(waitlock, end, false) };
- params.data.data_len = len;
+ params.data.data_len = len < 0 ? (strlen(data) + 1) : len;
params.data.data_val = data;
Device_WriteResp* resp = device_write_1(&params, context->clnt);
diff --git a/libvxi11client/libvxi11client.h b/libvxi11client/libvxi11client.h
index 4620abe..26a383f 100644
--- a/libvxi11client/libvxi11client.h
+++ b/libvxi11client/libvxi11client.h
@@ -28,7 +28,7 @@ int vxi11_open(VXI11Context* context, char* address, char* device);
int vxi11_abort(VXI11Context* context);
int vxi11_trigger(VXI11Context* context, bool waitforlock);
int vxi11_clear(VXI11Context* context, bool waitforlock);
-int vxi11_write(VXI11Context* context, char* data, unsigned int len, bool waitlock, bool end);
+int vxi11_write(VXI11Context* context, char* data, int len, bool waitlock, bool end);
int vxi11_read(VXI11Context* context, char* buffer, unsigned int bufferlen, bool waitlock, bool termchrset, char termchr);
int vxi11_lock(VXI11Context* context, bool waitforlock);
int vxi11_unlock(VXI11Context* context);
diff --git a/libvxi11client/perlbits/Client.xs b/libvxi11client/perlbits/Client.xs
index fc6194a..339444f 100644
--- a/libvxi11client/perlbits/Client.xs
+++ b/libvxi11client/perlbits/Client.xs
@@ -174,7 +174,7 @@ int
write(context,data, len, waitlock, end)
VXI11::Client context
char * data
- unsigned int len
+ int len
bool waitlock
bool end
CODE:
diff --git a/libvxi11client/perlbits/VXI11-Client.t b/libvxi11client/perlbits/VXI11-Client.t
index 691a6bb..f2e74b1 100644
--- a/libvxi11client/perlbits/VXI11-Client.t
+++ b/libvxi11client/perlbits/VXI11-Client.t
@@ -21,7 +21,7 @@ BEGIN { use_ok('VXI11::Client') };
my $instr = &VXI11::Client::open("roi", 0);
is($instr->lock(0), 1, "Lock");
-is($instr->write("*IDN?", 6, 0, 0), 6, "Write");
+ok($instr->write("*IDN?", -1, 0, 0) > 0, "Write");
ok($instr->readstatusbyte(0) >= 0 , "Read status byte");
is($instr->create_intr_chan(), 1, "Create intr channel");
is($instr->enable_srq(1, "myhandle"), 1, "Enable interrupts");
diff --git a/libvxi11client/perlbits/perlglue.c b/libvxi11client/perlbits/perlglue.c
index 3225ca0..902f915 100644
--- a/libvxi11client/perlbits/perlglue.c
+++ b/libvxi11client/perlbits/perlglue.c
@@ -19,8 +19,8 @@ static void freeevent(Event* event) {
static void freelast() {
if (lastevent != NULL) {
freeevent(lastevent);
+ lastevent = NULL;
}
- lastevent = NULL;
}
static void interruptcallback(char* handle) {