diff options
author | daniel <danieruru@gmail.com> | 2013-01-13 13:46:40 +0900 |
---|---|---|
committer | daniel <danieruru@gmail.com> | 2013-01-13 13:46:40 +0900 |
commit | 714b4e092f7dfc3bdbc6ea864e85cb144b1b7277 (patch) | |
tree | cb077b8541880c50139d13fbc8ffdce873f21176 /libvxi11client | |
parent | 7f2e52e8dbcda238268dd7339ba8c3dce908e252 (diff) |
Would help to actually pass the data read back out
Diffstat (limited to 'libvxi11client')
-rw-r--r-- | libvxi11client/client.c | 5 | ||||
-rw-r--r-- | libvxi11client/libvxi11client.c | 2 | ||||
-rw-r--r-- | libvxi11client/perlbits/README | 50 |
3 files changed, 55 insertions, 2 deletions
diff --git a/libvxi11client/client.c b/libvxi11client/client.c index 6b4496e..ee5fe47 100644 --- a/libvxi11client/client.c +++ b/libvxi11client/client.c @@ -56,9 +56,10 @@ int main(int argc, char *argv[]) { printf("Error writing data\n"); // read some bytes - int bytesread = vxi11_read(NULL, 0, false, false, 0); + char buffer[1024]; + int bytesread = vxi11_read(buffer, sizeof(buffer), false, false, 0); if (bytesread >= 0) - printf("Read %d bytes\n", bytesread); + printf("Read %d bytes, %s\n", bytesread, buffer); else printf("Error reading data\n"); diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c index 4697775..c58ad3a 100644 --- a/libvxi11client/libvxi11client.c +++ b/libvxi11client/libvxi11client.c @@ -215,6 +215,8 @@ int vxi11_read(char* buffer, unsigned int bufferlen, bool waitlock, bool termchr #ifdef DEBUG printf("Got \"%s\" from server\n", resp->data.data_val); #endif + if (buffer != NULL) + strncpy(buffer, resp->data.data_val, (bufferlen < resp->data.data_len ? bufferlen : resp->data.data_len)); return resp->data.data_len; } else if (resp == NULL) diff --git a/libvxi11client/perlbits/README b/libvxi11client/perlbits/README new file mode 100644 index 0000000..a789fc8 --- /dev/null +++ b/libvxi11client/perlbits/README @@ -0,0 +1,50 @@ +VXI11-Client version 0.01 +========================= + +This module is a wrapper around a C library that uses libc's built in +Sun RPC support to talk to VXI11 networked instruments. + +It supports only one instrument at a time. + +Interrupts work by creating the interrupt channel, enabling interrupts +and then using wait_for_interrupt() to wait for an interrupt to happen. +wait_for_interrupt() blocks until a interrupt happens or a timeout occurs. +If an interrupt happens before it is called it returns immediately. +If multiple interrupts happen before it is called it will return immediately +until all the fired interrupts are cleared. + +Return codes work like this; +1 - is a success +0 - means the request failed locally, the state inside the client is +incorrect, i.e. calling to enable interrupts before creating the channel +or that the server couldn't be contacted +< 0 - Any negative value is the negated VXI-11 error code from the server + +The only exceptions to this are the read and write methods +0 - Error as above or zero bytes read/written +> 0 - Number of bytes read/written + +INSTALLATION + +To install this module type the following: + + perl Makefile.PL + make + make test + make install + +DEPENDENCIES + +This module requires these other modules and libraries: + + glib/gthread + +COPYRIGHT AND LICENCE + +Put the correct copyright and licence information here. + +Copyright (C) 2013 by daniel + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself, either Perl version 5.14.2 or, +at your option, any later version of Perl 5 you may have available. |