summaryrefslogtreecommitdiff
path: root/libvxi11client
diff options
context:
space:
mode:
authordaniel <danieruru@gmail.com>2013-01-11 18:24:43 +0900
committerdaniel <danieruru@gmail.com>2013-01-11 18:24:43 +0900
commit7d4fa5278ace3dd96dda1bf4da75d617fd3e2795 (patch)
treeda903274305c49df85c7ac8f8d6cbf3385a6dfb9 /libvxi11client
parent2287a7ca37de5dadf9eda790e3afa96262cb9e76 (diff)
add more tests and a top level for perl wrapping
Diffstat (limited to 'libvxi11client')
-rw-r--r--libvxi11client/Makefile3
-rw-r--r--libvxi11client/client.c2
-rw-r--r--libvxi11client/libvxi11client.c6
-rw-r--r--libvxi11client/libvxi11client.h2
-rw-r--r--libvxi11client/perlbits/Makefile.PL4
-rw-r--r--libvxi11client/perlbits/VXI11-Client.t19
-rw-r--r--libvxi11client/perlglue.c66
-rw-r--r--libvxi11client/perlglue.h17
8 files changed, 108 insertions, 11 deletions
diff --git a/libvxi11client/Makefile b/libvxi11client/Makefile
index b313b63..2da0a08 100644
--- a/libvxi11client/Makefile
+++ b/libvxi11client/Makefile
@@ -26,8 +26,9 @@ clean:
perl:
-rm -rf VXI11-Client
- h2xs -A -M vxi11 -x -n VXI11::Client libvxi11client.h
+ h2xs -A -x -n VXI11::Client perlglue.h
cp vxi11.h libvxi11client.c libvxi11client.h vxi11_clnt.c vxi11_xdr.c VXI11-Client/
+ cp perlglue.c perlglue.h VXI11-Client/
cp perlbits/Makefile.PL VXI11-Client/
cp perlbits/VXI11-Client.t VXI11-Client/t/
cp perlbits/typemap VXI11-Client/
diff --git a/libvxi11client/client.c b/libvxi11client/client.c
index 77554f2..6b4496e 100644
--- a/libvxi11client/client.c
+++ b/libvxi11client/client.c
@@ -49,7 +49,7 @@ int main(int argc, char *argv[]) {
*/
// write some bytes
- int byteswritten = vxi11_write(IDENTIFY, sizeof(IDENTIFY), false);
+ int byteswritten = vxi11_write(IDENTIFY, sizeof(IDENTIFY), false, false);
if (byteswritten >= 0)
printf("Wrote %d bytes\n", byteswritten);
else
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c
index e33cb24..fb37dbc 100644
--- a/libvxi11client/libvxi11client.c
+++ b/libvxi11client/libvxi11client.c
@@ -211,8 +211,12 @@ int vxi11_read(char* buffer, unsigned int bufferlen, bool waitlock, bool termchr
termchrset ? termchr : 0 };
Device_ReadResp* resp = device_read_1(&params, clnt);
- if (resp != NULL && resp->error == 0)
+ if (resp != NULL && resp->error == 0) {
+#ifdef DEBUG
+ printf("Got \"%s\" from server\n", resp->data.data_val);
+#endif
return resp->data.data_len;
+ }
else if (resp == NULL)
return 0;
else
diff --git a/libvxi11client/libvxi11client.h b/libvxi11client/libvxi11client.h
index 5d25fae..d94662e 100644
--- a/libvxi11client/libvxi11client.h
+++ b/libvxi11client/libvxi11client.h
@@ -19,7 +19,7 @@ int vxi11_open(char* address, char* device);
int vxi11_abort(void);
int vxi11_trigger(bool waitforlock);
int vxi11_clear(bool waitforlock);
-int vxi11_write(char* data, unsigned int len, bool end);
+int vxi11_write(char* data, unsigned int len, bool waitlock, bool end);
int vxi11_read(char* buffer, unsigned int bufferlen, bool waitlock, bool termchrset, char termchr);
int vxi11_lock(bool waitforlock);
int vxi11_unlock(void);
diff --git a/libvxi11client/perlbits/Makefile.PL b/libvxi11client/perlbits/Makefile.PL
index 801c91f..9b7f0ff 100644
--- a/libvxi11client/perlbits/Makefile.PL
+++ b/libvxi11client/perlbits/Makefile.PL
@@ -9,9 +9,9 @@ WriteMakefile(
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/VXI11/Client.pm', # retrieve abstract from module
AUTHOR => 'daniel <daniel@>') : ()),
- LIBS => [''], # e.g., '-lm'
+ LIBS => ['-lgthread-2.0 -lrt -lglib-2.0'], # e.g., '-lm'
DEFINE => '', # e.g., '-DHAVE_SOMETHING'
- INC => '-I.', # e.g., '-I. -I/usr/include/other'
+ INC => '-I. -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include', # e.g., '-I. -I/usr/include/other'
OBJECT => '$(O_FILES)', # link all the C files too
);
if (eval {require ExtUtils::Constant; 1}) {
diff --git a/libvxi11client/perlbits/VXI11-Client.t b/libvxi11client/perlbits/VXI11-Client.t
index de10ecf..4d68c37 100644
--- a/libvxi11client/perlbits/VXI11-Client.t
+++ b/libvxi11client/perlbits/VXI11-Client.t
@@ -8,7 +8,7 @@
use strict;
use warnings;
-use Test::More tests => 5;
+use Test::More tests => 12;
BEGIN { use_ok('VXI11::Client') };
#########################
@@ -16,7 +16,16 @@ BEGIN { use_ok('VXI11::Client') };
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
-is(&VXI11::Client::vxi11_open("roi", 0), 1);
-is(&VXI11::Client::vxi11_lock(0), 1);
-is(&VXI11::Client::vxi11_unlock(), 1);
-is(&VXI11::Client::vxi11_close(), 1);
+is(&VXI11::Client::vopen("roi", 0), 1);
+is(&VXI11::Client::vlock(0), 1);
+is(&VXI11::Client::vwrite("*IDN?", 6, 0, 0), 6);
+ok(&VXI11::Client::vreadstatusbyte(0) >= 0 , "Read status byte");
+# is(&VXI11::Client::vcreate_intr_chan(), 1);
+# is(&VXI11::Client::vdestroy_intr_chan(), 1);
+is(&VXI11::Client::vabort(), 1);
+is(&VXI11::Client::vclear(0), 1);
+is(&VXI11::Client::vtrigger(0), 1);
+is(&VXI11::Client::vlocal(0), 1);
+is(&VXI11::Client::vremote(0), 1);
+is(&VXI11::Client::vunlock(), 1);
+is(&VXI11::Client::vclose(), 1);
diff --git a/libvxi11client/perlglue.c b/libvxi11client/perlglue.c
new file mode 100644
index 0000000..937b9e4
--- /dev/null
+++ b/libvxi11client/perlglue.c
@@ -0,0 +1,66 @@
+#include "perlglue.h"
+#include "libvxi11client.h"
+#include <stdbool.h>
+
+int vopen(char* address, char* device) {
+ return vxi11_open(address, device);
+}
+
+int vabort(void) {
+ return vxi11_abort();
+}
+
+int vtrigger(bool waitforlock) {
+ return vxi11_trigger(waitforlock);
+}
+
+int vclear(bool waitforlock) {
+ return vxi11_clear(waitforlock);
+}
+
+int vwrite(char* data, unsigned int len, bool waitlock, bool end) {
+ return vxi11_write(data, len, waitlock, end);
+}
+
+int vread(char* buffer, unsigned int bufferlen, bool waitlock, bool termchrset, char termchr) {
+ return vxi11_read(buffer, bufferlen, waitlock, termchrset, termchr);
+}
+
+int vlock(bool waitforlock) {
+ return vxi11_lock(waitforlock);
+}
+
+int vunlock(void) {
+ return vxi11_unlock();
+}
+
+int vlocal(bool waitforlock) {
+ return vxi11_local(waitforlock);
+}
+
+int vremote(bool waitforlock) {
+ return vxi11_remote(waitforlock);
+}
+
+int vreadstatusbyte(bool waitforlock) {
+ return vxi11_readstatusbyte(waitforlock);
+}
+
+int vcreate_intr_chan(void) {
+ return vxi11_create_intr_chan();
+}
+
+int vdestroy_intr_chan(void) {
+ return vxi11_destroy_intr_chan();
+}
+
+int venable_srq(bool enable, char* handle) {
+}
+
+int vdocmd(unsigned long cmd, bool waitforlock) {
+ return vxi11_docmd(cmd, waitforlock);
+}
+
+int vclose(void) {
+ return vxi11_close();
+}
diff --git a/libvxi11client/perlglue.h b/libvxi11client/perlglue.h
new file mode 100644
index 0000000..8dd17df
--- /dev/null
+++ b/libvxi11client/perlglue.h
@@ -0,0 +1,17 @@
+#include <stdbool.h>
+int vopen(char* address, char* device);
+int vabort(void);
+int vtrigger(bool waitforlock);
+int vclear(bool waitforlock);
+int vwrite(char* data, unsigned int len, bool waitlock, bool end);
+int vread(char* buffer, unsigned int bufferlen, bool waitlock, bool termchrset, char termchr);
+int vlock(bool waitforlock);
+int vunlock(void);
+int vlocal(bool waitforlock);
+int vremote(bool waitforlock);
+int vreadstatusbyte(bool waitforlock);
+int vcreate_intr_chan(void);
+int vdestroy_intr_chan(void);
+int venable_srq(bool enable, char* handle);
+int vdocmd(unsigned long cmd, bool waitforlock);
+int vclose(void);