diff options
author | daniel <danieruru@gmail.com> | 2013-01-09 14:02:09 +0900 |
---|---|---|
committer | daniel <danieruru@gmail.com> | 2013-01-09 14:02:09 +0900 |
commit | ee9413282d02d936185dc88a34bb817a1a273e6d (patch) | |
tree | 159f3b558a9da24c4b0166889d11f2833dc72e99 /libvxi11client/libvxi11client.c | |
parent | c4ef0522de10e86ff7af432066123e59665913c4 (diff) |
A few more clean ups
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) |