summaryrefslogtreecommitdiff
path: root/libvxi11client
diff options
context:
space:
mode:
authordaniel <danieruru@gmail.com>2013-01-09 14:45:33 +0900
committerdaniel <danieruru@gmail.com>2013-01-09 14:45:33 +0900
commit57bec4c29edc96491328c8f60fe76055ab2f4008 (patch)
tree4b4f5adf6015e3bde96975601992df44a7a574eb /libvxi11client
parent2c93550a5394c632ae6b820e38ca75ab5df5aae7 (diff)
add a waitlock parameter to all of the calls that care about it
Diffstat (limited to 'libvxi11client')
-rw-r--r--libvxi11client/client.c18
-rw-r--r--libvxi11client/libvxi11client.c42
-rw-r--r--libvxi11client/libvxi11client.h24
3 files changed, 43 insertions, 41 deletions
diff --git a/libvxi11client/client.c b/libvxi11client/client.c
index 799df57..2d050aa 100644
--- a/libvxi11client/client.c
+++ b/libvxi11client/client.c
@@ -52,11 +52,11 @@ int main(int argc, char *argv[]) {
printf("Error reading data\n");
// trigger
- if (vxi11_trigger() > 0)
+ if (vxi11_trigger(false) > 0)
printf("triggered\n");
// clear
- if (vxi11_clear() > 0)
+ if (vxi11_clear(false) > 0)
printf("cleared\n");
// abort
@@ -66,7 +66,7 @@ int main(int argc, char *argv[]) {
printf("abort failed; %s\n", geterrorstring(err));
// lock
- if ((err = vxi11_lock()) > 0)
+ if ((err = vxi11_lock(false)) > 0)
printf("locked\n");
// unlock
@@ -74,15 +74,15 @@ int main(int argc, char *argv[]) {
printf("unlocked\n");
// remote
- if ((err = vxi11_remote()) > 0)
+ if ((err = vxi11_remote(false)) > 0)
printf("remote'd\n");
// local
- if ((err = vxi11_local()) > 0)
+ if ((err = vxi11_local(false)) > 0)
printf("local'd\n");
// read the status byte
- int statusbyte = vxi11_readstatusbyte();
+ int statusbyte = vxi11_readstatusbyte(false);
if (statusbyte >= 0)
printf("Status byte is 0x%02x\n", statusbyte);
else
@@ -94,9 +94,9 @@ int main(int argc, char *argv[]) {
// try locking twice
printf("-- Locking twice --\n");
- if ((err = vxi11_lock()) > 0) {
+ if ((err = vxi11_lock(false)) > 0) {
printf("locked\n");
- if ((err = vxi11_lock()) > 0) {
+ if ((err = vxi11_lock(false)) > 0) {
printf("locked again!!\n");
exit(1);
}
@@ -133,7 +133,7 @@ int main(int argc, char *argv[]) {
printf("Error destroying interrupt channel; %s\n", geterrorstring(err));
// docmd
- if ((err = vxi11_docmd(0x00)) > 0)
+ if ((err = vxi11_docmd(0x00, false)) > 0)
printf("did command, should fail!\n");
else
printf("Error calling docmd; %s\n", geterrorstring(err));
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c
index 4e3efd0..6234c0f 100644
--- a/libvxi11client/libvxi11client.c
+++ b/libvxi11client/libvxi11client.c
@@ -59,12 +59,12 @@ int vxi11_open(char* address, char* device) {
* read the status byte of the connected server
*/
-int vxi11_readstatusbyte() {
+int vxi11_readstatusbyte(bool waitforlock) {
if (clnt == NULL)
return 0;
- Device_GenericParms params = { .lid = link, .flags = 0x0, .lock_timeout = VXI11_DEFAULT_TIMEOUT, .io_timeout =
- VXI11_DEFAULT_TIMEOUT };
+ Device_GenericParms params = { .lid = link, .flags = vxi11_generateflags(waitforlock, false, false), .lock_timeout =
+ VXI11_DEFAULT_TIMEOUT, .io_timeout = VXI11_DEFAULT_TIMEOUT };
Device_ReadStbResp* resp = device_readstb_1(&params, clnt);
if (resp != NULL && resp->error == 0)
@@ -122,12 +122,13 @@ int vxi11_read(char* buffer, unsigned int bufferlen, bool waitlock, bool termchr
*
*/
-int vxi11_docmd(unsigned long cmd) {
+int vxi11_docmd(unsigned long cmd, bool waitforlock) {
if (clnt == NULL)
return 0;
- Device_DocmdParms params = { .lid = link, .flags = 0x0, .io_timeout = VXI11_DEFAULT_TIMEOUT, .lock_timeout =
- VXI11_DEFAULT_TIMEOUT, .cmd = cmd, .network_order = 0, .datasize = 0 };
+ Device_DocmdParms params =
+ { .lid = link, .flags = vxi11_generateflags(waitforlock, false, false), .io_timeout = VXI11_DEFAULT_TIMEOUT,
+ .lock_timeout = VXI11_DEFAULT_TIMEOUT, .cmd = cmd, .network_order = 0, .datasize = 0 };
params.data_in.data_in_len = 0;
params.data_in.data_in_val = NULL;
@@ -145,12 +146,12 @@ int vxi11_docmd(unsigned long cmd) {
* trigger the connected device
*/
-int vxi11_trigger() {
+int vxi11_trigger(bool waitforlock) {
if (clnt == NULL)
return 0;
- Device_GenericParms params = { .lid = link, .flags = 0x0, .lock_timeout = VXI11_DEFAULT_TIMEOUT, .io_timeout =
- VXI11_DEFAULT_TIMEOUT };
+ Device_GenericParms params = { .lid = link, .flags = vxi11_generateflags(waitforlock, false, false), .lock_timeout =
+ VXI11_DEFAULT_TIMEOUT, .io_timeout = VXI11_DEFAULT_TIMEOUT };
Device_Error* error = device_trigger_1(&params, clnt);
if (error->error == 0)
@@ -163,11 +164,11 @@ int vxi11_trigger() {
* clear the connected device
*/
-int vxi11_clear() {
+int vxi11_clear(bool waitforlock) {
if (clnt == NULL)
return 0;
- Device_GenericParms params = { .lid = link, .flags = 0x0, .lock_timeout = VXI11_DEFAULT_TIMEOUT, .io_timeout =
- VXI11_DEFAULT_TIMEOUT };
+ Device_GenericParms params = { .lid = link, .flags = vxi11_generateflags(waitforlock, false, false), .lock_timeout =
+ VXI11_DEFAULT_TIMEOUT, .io_timeout = VXI11_DEFAULT_TIMEOUT };
Device_Error* error = device_clear_1(&params, clnt);
if (error != NULL && error->error == 0)
return 1;
@@ -181,11 +182,11 @@ int vxi11_clear() {
* remote the connected device
*/
-int vxi11_remote() {
+int vxi11_remote(bool waitforlock) {
if (clnt == NULL)
return 0;
- Device_GenericParms params = { .lid = link, .flags = 0x0, .lock_timeout = VXI11_DEFAULT_TIMEOUT, .io_timeout =
- VXI11_DEFAULT_TIMEOUT };
+ Device_GenericParms params = { .lid = link, .flags = vxi11_generateflags(waitforlock, false, false), .lock_timeout =
+ VXI11_DEFAULT_TIMEOUT, .io_timeout = VXI11_DEFAULT_TIMEOUT };
Device_Error* error = device_remote_1(&params, clnt);
if (error != NULL && error->error == 0)
return 1;
@@ -199,11 +200,11 @@ int vxi11_remote() {
* local the connected device
*/
-int vxi11_local() {
+int vxi11_local(bool waitforlock) {
if (clnt == NULL)
return 0;
- Device_GenericParms params = { .lid = link, .flags = 0x0, .lock_timeout = VXI11_DEFAULT_TIMEOUT, .io_timeout =
- VXI11_DEFAULT_TIMEOUT };
+ Device_GenericParms params = { .lid = link, .flags = vxi11_generateflags(waitforlock, false, false), .lock_timeout =
+ VXI11_DEFAULT_TIMEOUT, .io_timeout = VXI11_DEFAULT_TIMEOUT };
Device_Error* error = device_local_1(&params, clnt);
if (error != NULL && error->error == 0)
return 1;
@@ -217,10 +218,11 @@ int vxi11_local() {
* lock the connected device
*/
-int vxi11_lock() {
+int vxi11_lock(bool waitforlock) {
if (clnt == NULL)
return 0;
- Device_LockParms params = { .lid = link, .flags = 0x0, .lock_timeout = VXI11_DEFAULT_TIMEOUT };
+ Device_LockParms params = { .lid = link, .flags = vxi11_generateflags(waitforlock, false, false), .lock_timeout =
+ VXI11_DEFAULT_TIMEOUT };
Device_Error* error = device_lock_1(&params, clnt);
if (error != NULL && error->error == 0)
return 1;
diff --git a/libvxi11client/libvxi11client.h b/libvxi11client/libvxi11client.h
index 6f92744..b76fe55 100644
--- a/libvxi11client/libvxi11client.h
+++ b/libvxi11client/libvxi11client.h
@@ -17,17 +17,17 @@
#define ERR_CHANNELALREADYESTABLISHED -29
int vxi11_open(char* address, char* device);
-int vxi11_abort();
-int vxi11_trigger();
-int vxi11_clear();
+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_read(char* buffer, unsigned int bufferlen, bool waitlock, bool termchrset, char termchr);
-int vxi11_lock();
-int vxi11_unlock();
-int vxi11_local();
-int vxi11_readstatusbyte();
-int vxi11_remote();
-int vxi11_create_intr_chan();
-int vxi11_destroy_intr_chan();
-int vxi11_docmd(unsigned long cmd);
-int vxi11_close();
+int vxi11_lock(bool waitforlock);
+int vxi11_unlock(void);
+int vxi11_local(bool waitforlock);
+int vxi11_remote(bool waitforlock);
+int vxi11_readstatusbyte(bool waitforlock);
+int vxi11_create_intr_chan(void);
+int vxi11_destroy_intr_chan(void);
+int vxi11_docmd(unsigned long cmd, bool waitforlock);
+int vxi11_close(void);