summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaniel <danieruru@gmail.com>2013-01-05 21:10:23 +0900
committerdaniel <danieruru@gmail.com>2013-01-05 21:10:23 +0900
commit616248011d26981b6b54225ee359cb4a5d43f05d (patch)
tree5afcd15e42e0d86ba5718b059349ea9f231f9627
parent18fb047d74d3078223a0a27ffcd31e3467b0d27d (diff)
fix broken logic
-rw-r--r--libvxi11client/client.c32
-rw-r--r--vxi11_server.c6
2 files changed, 22 insertions, 16 deletions
diff --git a/libvxi11client/client.c b/libvxi11client/client.c
index d75ddd5..f946547 100644
--- a/libvxi11client/client.c
+++ b/libvxi11client/client.c
@@ -7,6 +7,8 @@ static char* geterrorstring(int errorcode) {
switch (errorcode) {
case 0:
return "no response from server";
+ case -8:
+ return "operation not supported";
default:
return "unknown error code";
}
@@ -17,7 +19,7 @@ int main() {
int err = 0;
- if (vxi11_open("192.168.2.250")) {
+ if ((err = vxi11_open("192.168.2.250")) > 0) {
// write some bytes
int byteswritten = vxi11_write(IDENTIFY, sizeof(IDENTIFY));
@@ -34,33 +36,33 @@ int main() {
printf("Error reading data\n");
// trigger
- if (vxi11_trigger())
+ if (vxi11_trigger() > 0)
printf("triggered\n");
// clear
- if (vxi11_clear())
+ if (vxi11_clear() > 0)
printf("cleared\n");
// abort
- if ((err = vxi11_abort()))
+ if ((err = vxi11_abort()) > 0)
printf("aborted\n");
else
printf("abort failed; %s\n", geterrorstring(err));
// lock
- if (vxi11_lock())
+ if ((err = vxi11_lock()) > 0)
printf("locked\n");
// unlock
- if (vxi11_unlock())
+ if ((err = vxi11_unlock()) > 0)
printf("unlocked\n");
// remote
- if (vxi11_remote())
+ if ((err = vxi11_remote()) > 0)
printf("remote'd\n");
// local
- if (vxi11_local())
+ if ((err = vxi11_local()) > 0)
printf("local'd\n");
// read the status byte
@@ -71,24 +73,26 @@ int main() {
printf("Error reading status byte\n");
// create interrupt channel
- vxi11_create_intr_chan();
+ err = vxi11_create_intr_chan();
// destroy interrupt channel
- if ((err = vxi11_destroy_intr_chan()))
+ if ((err = vxi11_destroy_intr_chan()) > 0)
printf("destroyed interrupt channel\n");
else
printf("Error destroying interrupt channel; %s\n", geterrorstring(err));
// docmd
- if ((err = vxi11_docmd(0x00)))
- printf("did command, should fail!\n");
+ if ((err = vxi11_docmd(0x00)) > 0)
+ printf("did command, should fail! %d\n");
else
- printf("Error calling docmd; %\n", geterrorstring(err));
+ printf("Error calling docmd; %s\n", geterrorstring(err));
// close
- vxi11_close();
+ if ((err = vxi11_close() > 0))
+ printf("Closed\n");
}
else {
+ printf("Error opening device; %s\n", geterrorstring(err));
exit(1);
}
}
diff --git a/vxi11_server.c b/vxi11_server.c
index 84a80d5..3272b32 100644
--- a/vxi11_server.c
+++ b/vxi11_server.c
@@ -37,13 +37,13 @@ static void waitForLock(long timeout) {
}
static bool lock(int lid) {
- if (globals.VxiLocks.locked_network_server = NO_SERVER_LOCKED)
+ if ((globals.VxiLocks.locked_network_server = NO_SERVER_LOCKED))
return false;
globals.VxiLocks.locked_network_server = lid;
}
static bool unlock(int lid) {
- if (globals.VxiLocks.locked_network_server = NO_SERVER_LOCKED)
+ if ((globals.VxiLocks.locked_network_server = NO_SERVER_LOCKED))
return false;
else if (globals.VxiLocks.locked_network_server != lid)
return false;
@@ -198,6 +198,8 @@ Device_DocmdResp *
device_docmd_1_svc(Device_DocmdParms *argp, struct svc_req *rqstp) {
printf("device_docmd_1_svc()\n");
static Device_DocmdResp result;
+ result.data_out.data_out_len = 0;
+ result.data_out.data_out_val = NULL;
result.error = ERR_OPERATIONNOTSUPPORTED;
return &result;
}