diff options
Diffstat (limited to 'libvxi11client/libvxi11client.c')
-rw-r--r-- | libvxi11client/libvxi11client.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c index 0cb4ab9..ba7d7b4 100644 --- a/libvxi11client/libvxi11client.c +++ b/libvxi11client/libvxi11client.c @@ -1,3 +1,4 @@ +#include <stdbool.h> #include "vxi11.h" /** @@ -5,11 +6,26 @@ * Only one server with a single link is supported. */ +#define FLAG_TERMCHRSET (1 << 7) +#define FLAG_END (1 << 3) +#define FLAG_WAITLOCK 1 + #define VXI11_DEFAULT_TIMEOUT 1000 static CLIENT* clnt = NULL; static Device_Link link; +static Device_Flags vxi11_generateflags(bool waitlock, bool end, bool termchrset) { + Device_Flags flags = 0; + if (waitlock) + flags |= FLAG_WAITLOCK; + if (end) + flags |= FLAG_END; + if (termchrset) + flags |= FLAG_TERMCHRSET; + return flags; +} + /** * create an RPC client and open a link to the server at $address. * $device is apparently used for VXI-11 -> GPIB gateways.. this is untested. @@ -63,12 +79,12 @@ int vxi11_readstatusbyte() { * write to the connected device */ -int vxi11_write(char* data, unsigned int len) { +int vxi11_write(char* data, unsigned int len, bool waitlock, bool end) { if (clnt == NULL) return 0; Device_WriteParms params = { .lid = link, .io_timeout = VXI11_DEFAULT_TIMEOUT, - .lock_timeout = VXI11_DEFAULT_TIMEOUT, .flags = 0x0 }; + .lock_timeout = VXI11_DEFAULT_TIMEOUT, .flags = vxi11_generateflags(waitlock, end, false) }; params.data.data_len = len; params.data.data_val = data; @@ -85,12 +101,13 @@ int vxi11_write(char* data, unsigned int len) { * read from the connected device */ -int vxi11_read() { +int vxi11_read(char* buffer, unsigned int bufferlen, bool waitlock, bool termchrset, char termchr) { if (clnt == NULL) return 0; Device_ReadParms params = { .lid = link, .requestSize = 256, .io_timeout = VXI11_DEFAULT_TIMEOUT, .lock_timeout = - VXI11_DEFAULT_TIMEOUT, .flags = 0x0, .termChar = 0x0 }; + VXI11_DEFAULT_TIMEOUT, .flags = vxi11_generateflags(waitlock, false, termchrset), .termChar = + termchrset ? termchr : 0 }; Device_ReadResp* resp = device_read_1(¶ms, clnt); if (resp != NULL && resp->error == 0) |