diff options
Diffstat (limited to 'libvxi11client/client.c')
-rw-r--r-- | libvxi11client/client.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/libvxi11client/client.c b/libvxi11client/client.c index ee5fe47..b851347 100644 --- a/libvxi11client/client.c +++ b/libvxi11client/client.c @@ -40,16 +40,18 @@ int main(int argc, char *argv[]) { exit(1); } + Context ctx; + int err = 0; - if ((err = vxi11_open(argv[1], NULL)) > 0) { + if ((err = vxi11_open(&ctx, argv[1], NULL)) > 0) { /** * Basic tests */ // write some bytes - int byteswritten = vxi11_write(IDENTIFY, sizeof(IDENTIFY), false, false); + int byteswritten = vxi11_write(&ctx, IDENTIFY, sizeof(IDENTIFY), false, false); if (byteswritten >= 0) printf("Wrote %d bytes\n", byteswritten); else @@ -57,44 +59,44 @@ int main(int argc, char *argv[]) { // read some bytes char buffer[1024]; - int bytesread = vxi11_read(buffer, sizeof(buffer), false, false, 0); + int bytesread = vxi11_read(&ctx, buffer, sizeof(buffer), false, false, 0); if (bytesread >= 0) printf("Read %d bytes, %s\n", bytesread, buffer); else printf("Error reading data\n"); // trigger - if (vxi11_trigger(false) > 0) + if (vxi11_trigger(&ctx, false) > 0) printf("triggered\n"); // clear - if (vxi11_clear(false) > 0) + if (vxi11_clear(&ctx, false) > 0) printf("cleared\n"); // abort - if ((err = vxi11_abort()) > 0) + if ((err = vxi11_abort(&ctx)) > 0) printf("aborted\n"); else printf("abort failed; %s\n", geterrorstring(err)); // lock - if ((err = vxi11_lock(false)) > 0) + if ((err = vxi11_lock(&ctx, false)) > 0) printf("locked\n"); // unlock - if ((err = vxi11_unlock()) > 0) + if ((err = vxi11_unlock(&ctx)) > 0) printf("unlocked\n"); // remote - if ((err = vxi11_remote(false)) > 0) + if ((err = vxi11_remote(&ctx, false)) > 0) printf("remote'd\n"); // local - if ((err = vxi11_local(false)) > 0) + if ((err = vxi11_local(&ctx, false)) > 0) printf("local'd\n"); // read the status byte - int statusbyte = vxi11_readstatusbyte(false); + int statusbyte = vxi11_readstatusbyte(&ctx, false); if (statusbyte >= 0) printf("Status byte is 0x%02x\n", statusbyte); else @@ -106,9 +108,9 @@ int main(int argc, char *argv[]) { // try locking twice printf("-- Locking twice --\n"); - if ((err = vxi11_lock(false)) > 0) { + if ((err = vxi11_lock(&ctx, false)) > 0) { printf("locked\n"); - if ((err = vxi11_lock(false)) > 0) { + if ((err = vxi11_lock(&ctx, false)) > 0) { printf("locked again!!\n"); exit(1); } @@ -116,7 +118,7 @@ int main(int argc, char *argv[]) { printf("Second lock failed; %s\n", geterrorstring(err)); } } - if ((err = vxi11_unlock()) > 0) + if ((err = vxi11_unlock(&ctx)) > 0) printf("unlocked\n"); else { printf("error unlocking; %s\n", geterrorstring(err)); @@ -127,7 +129,7 @@ int main(int argc, char *argv[]) { // try unlocking unlocked device printf("-- Unlocking when unlocked --\n"); - if ((err = vxi11_unlock()) > 0) { + if ((err = vxi11_unlock(&ctx)) > 0) { printf("Unlocked!!\n"); exit(1); } @@ -138,11 +140,11 @@ int main(int argc, char *argv[]) { // Interrupt channel tests printf("-- Testing interrupt channel --\n"); // create interrupt channel - if ((err = vxi11_create_intr_chan()) > 0) { + if ((err = vxi11_create_intr_chan(&ctx)) > 0) { printf("Created interrupt channel\n"); // enable interrupts - if ((err = vxi11_enable_srq(true, "handle", interruptcallback)) > 0) + if ((err = vxi11_enable_srq(&ctx, true, "handle", interruptcallback)) > 0) printf("Enabled interrupts\n"); else printf("Error enabling interrupts; %s\n", geterrorstring(err)); @@ -150,13 +152,13 @@ int main(int argc, char *argv[]) { sleep(10); // disable interrupts - if ((err = vxi11_enable_srq(false, NULL, NULL)) > 0) + if ((err = vxi11_enable_srq(&ctx, false, NULL, NULL)) > 0) printf("Disabled interrupts\n"); else printf("Error disabling interrupts; %s\n", geterrorstring(err)); // destroy interrupt channel - if ((err = vxi11_destroy_intr_chan()) > 0) + if ((err = vxi11_destroy_intr_chan(&ctx)) > 0) printf("Destroyed interrupt channel\n"); else printf("Error destroying interrupt channel; %s\n", geterrorstring(err)); @@ -166,13 +168,13 @@ int main(int argc, char *argv[]) { printf("\n"); // docmd - if ((err = vxi11_docmd(0x00, false)) > 0) + if ((err = vxi11_docmd(&ctx, 0x00, false)) > 0) printf("did command, should fail!\n"); else printf("Error calling docmd; %s\n", geterrorstring(err)); // close - if ((err = vxi11_close() > 0)) + if ((err = vxi11_close(&ctx) > 0)) printf("Closed\n"); } else { |