diff options
author | daniel <danieruru@gmail.com> | 2013-01-05 20:56:25 +0900 |
---|---|---|
committer | daniel <danieruru@gmail.com> | 2013-01-05 20:56:25 +0900 |
commit | 18fb047d74d3078223a0a27ffcd31e3467b0d27d (patch) | |
tree | 023107523d0f799a92ba31234b508e021630552d /libvxi11client/client.c | |
parent | e5656b476c9168cfe7852bce4e2ce59876a45d12 (diff) |
A bit more fleshing out of the VXI server and client
Diffstat (limited to 'libvxi11client/client.c')
-rw-r--r-- | libvxi11client/client.c | 104 |
1 files changed, 88 insertions, 16 deletions
diff --git a/libvxi11client/client.c b/libvxi11client/client.c index fe023c7..d75ddd5 100644 --- a/libvxi11client/client.c +++ b/libvxi11client/client.c @@ -1,22 +1,94 @@ #include "vxi11.h" #include <stdio.h> +#define IDENTIFY "*IDN?" + +static char* geterrorstring(int errorcode) { + switch (errorcode) { + case 0: + return "no response from server"; + default: + return "unknown error code"; + } +} + int main() { printf("VXI-11 test client\n"); - CLIENT* clnt; - vxi11_open("192.168.2.250"); - vxi11_write(); - vxi11_read(); - vxi11_trigger(); - vxi11_clear(); - vxi11_abort(); - vxi11_lock(); - vxi11_unlock(); - vxi11_remote(); - vxi11_local(); - vxi11_readstatusbyte(); - vxi11_create_intr_chan(); - vxi11_destroy_intr_chan(); - vxi11_docmd(); - vxi11_close(); + + int err = 0; + + if (vxi11_open("192.168.2.250")) { + + // write some bytes + int byteswritten = vxi11_write(IDENTIFY, sizeof(IDENTIFY)); + if (byteswritten >= 0) + printf("Wrote %d bytes\n", byteswritten); + else + printf("Error writing data\n"); + + // read some bytes + int bytesread = vxi11_read(); + if (bytesread >= 0) + printf("Read %d bytes\n", bytesread); + else + printf("Error reading data\n"); + + // trigger + if (vxi11_trigger()) + printf("triggered\n"); + + // clear + if (vxi11_clear()) + printf("cleared\n"); + + // abort + if ((err = vxi11_abort())) + printf("aborted\n"); + else + printf("abort failed; %s\n", geterrorstring(err)); + + // lock + if (vxi11_lock()) + printf("locked\n"); + + // unlock + if (vxi11_unlock()) + printf("unlocked\n"); + + // remote + if (vxi11_remote()) + printf("remote'd\n"); + + // local + if (vxi11_local()) + printf("local'd\n"); + + // read the status byte + int statusbyte = vxi11_readstatusbyte(); + if (statusbyte >= 0) + printf("Status byte is 0x%02x\n", statusbyte); + else + printf("Error reading status byte\n"); + + // create interrupt channel + vxi11_create_intr_chan(); + + // destroy interrupt channel + if ((err = vxi11_destroy_intr_chan())) + 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"); + else + printf("Error calling docmd; %\n", geterrorstring(err)); + + // close + vxi11_close(); + } + else { + exit(1); + } } |