summaryrefslogtreecommitdiff
path: root/libvxi11client/libvxi11client.c
diff options
context:
space:
mode:
authordaniel <danieruru@gmail.com>2013-01-05 16:30:05 +0900
committerdaniel <danieruru@gmail.com>2013-01-05 16:30:05 +0900
commitc70c87d3865c9e591b08c2d49cccbc776a136fab (patch)
treebe4b67b462d4238a94d09399855011390d2fc273 /libvxi11client/libvxi11client.c
parent42d30a78def5b5a0f48ce47f0e8cd77eaf8a2452 (diff)
add a work in progress "vxi-11 client library" and test client.. this will become the perl module later
Diffstat (limited to 'libvxi11client/libvxi11client.c')
-rw-r--r--libvxi11client/libvxi11client.c128
1 files changed, 128 insertions, 0 deletions
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c
new file mode 100644
index 0000000..bfe56fa
--- /dev/null
+++ b/libvxi11client/libvxi11client.c
@@ -0,0 +1,128 @@
+#include "vxi11.h"
+
+#define VXI11_DEFAULT_TIMEOUT 1000
+
+static CLIENT* clnt = NULL;
+static Device_Link link;
+
+void vxi11_open(char* address, char* device) {
+ clnt = clnt_create(address, DEVICE_CORE, DEVICE_CORE_VERSION, "tcp");
+ if (clnt == NULL) {
+ printf("error creating client\n");
+ }
+ else {
+ Create_LinkParms link_parms;
+ link_parms.clientId = (long) clnt;
+ link_parms.lockDevice = 0;
+ link_parms.lock_timeout = VXI11_DEFAULT_TIMEOUT;
+ link_parms.device = device;
+
+ Create_LinkResp* linkresp = create_link_1(&link_parms, clnt);
+ link = linkresp->lid;
+ }
+}
+
+void vxi11_readstatusbyte() {
+
+}
+
+void vxi11_write() {
+ if (clnt == NULL) {
+ return;
+ }
+
+ char* IDENTIFY = "*IDN?";
+
+ Device_WriteParms
+ params = {.lid = link, .io_timeout = VXI11_DEFAULT_TIMEOUT, .lock_timeout = VXI11_DEFAULT_TIMEOUT, .flags = 0x0};
+ params.data.data_len = sizeof(IDENTIFY);
+ params.data.data_val = IDENTIFY;
+
+ Device_WriteResp* resp = device_write_1(&params, clnt);
+}
+
+void vxi11_read() {
+ if (clnt == NULL) {
+ return;
+ }
+
+ Device_ReadParms
+ params = {.lid = link, .requestSize = 256, .io_timeout = VXI11_DEFAULT_TIMEOUT, .lock_timeout = VXI11_DEFAULT_TIMEOUT, .flags = 0x0, .termChar = 0x0};
+
+ Device_ReadResp* resp = device_read_1(&params, clnt);
+}
+
+void vxi11_docmd() {
+
+}
+
+void vxi11_trigger() {
+ if (clnt == NULL)
+ return;
+
+ Device_GenericParms
+ params = {.lid = link, .flags = 0x0, .lock_timeout = VXI11_DEFAULT_TIMEOUT, .io_timeout=VXI11_DEFAULT_TIMEOUT};
+ device_trigger_1(&params, clnt);
+}
+
+void vxi11_clear() {
+ if (clnt == NULL)
+ return;
+ Device_GenericParms
+ params = {.lid = link, .flags = 0x0, .lock_timeout = VXI11_DEFAULT_TIMEOUT, .io_timeout=VXI11_DEFAULT_TIMEOUT};
+ device_clear_1(&params, clnt);
+}
+
+void vxi11_remote() {
+ if (clnt == NULL)
+ return;
+ Device_GenericParms
+ params = {.lid = link, .flags = 0x0, .lock_timeout = VXI11_DEFAULT_TIMEOUT, .io_timeout=VXI11_DEFAULT_TIMEOUT};
+ device_remote_1(&params, clnt);
+}
+
+void vxi11_local() {
+ if (clnt == NULL)
+ return;
+ Device_GenericParms
+ params = {.lid = link, .flags = 0x0, .lock_timeout = VXI11_DEFAULT_TIMEOUT, .io_timeout=VXI11_DEFAULT_TIMEOUT};
+ device_local_1(&params, clnt);
+}
+
+void vxi11_lock() {
+ if (clnt == NULL)
+ return;
+ Device_LockParms
+ params = {.lid = link, .flags = 0x0, .lock_timeout = VXI11_DEFAULT_TIMEOUT};
+ device_lock_1(&params, clnt);
+}
+
+void vxi11_unlock() {
+ if (clnt == NULL)
+ return;
+ device_unlock_1(&link, clnt);
+}
+
+void vxi11_create_intr_chan() {
+ if (clnt == NULL)
+ return;
+
+}
+
+void vxi11_destroy_intr_chan() {
+ if (clnt == NULL)
+ return;
+
+}
+
+void vxi11_abort() {
+ if (clnt == NULL)
+ return;
+ device_abort_1(&link, clnt);
+}
+
+void vxi11_close() {
+ destroy_link_1(&link, clnt);
+ clnt_destroy(clnt);
+ clnt = NULL;
+}