summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--instr-daemon.c2
-rw-r--r--vxi11_server.c37
2 files changed, 24 insertions, 15 deletions
diff --git a/instr-daemon.c b/instr-daemon.c
index b0e05cd..e1d5c8e 100644
--- a/instr-daemon.c
+++ b/instr-daemon.c
@@ -15,6 +15,7 @@
#include <stdlib.h>
#include <ctype.h>
#include <glib.h>
+#include <unistd.h>
#include <fcntl.h>
#define STDIN_BUF_SIZE 1024
@@ -352,7 +353,6 @@ static gboolean finish_boot (void)
return FALSE; // no more calls to this function are needed
}
-
static gboolean periodic_poll (void)
{
if (globals.HWDetect.beaglebone && bus_getpin (POWER_FAIL)) {
diff --git a/vxi11_server.c b/vxi11_server.c
index 1d66688..4c3a837 100644
--- a/vxi11_server.c
+++ b/vxi11_server.c
@@ -1,5 +1,7 @@
#include "vxi11.h"
#include "globals.h"
+#include "gpib.h"
+#include "parser.h"
#include <stdio.h>
#include <rpc/rpc.h>
#include <stdbool.h>
@@ -48,7 +50,12 @@ static bool haveLock(int lid) {
return globals.VxiLocks.locked_network_server == lid;
}
-static bool waitForLock(long timeout) {
+#define FLAG_WAITLOCK 1
+
+// todo
+static bool waitForLock(Device_Flags flags, long timeout) {
+ if (!(flags & FLAG_WAITLOCK))
+ return false;
return false;
}
@@ -84,7 +91,7 @@ create_link_1_svc(Create_LinkParms *argp, struct svc_req *rqstp) {
result.error = ERR_OUTOFRESOURCES;
}
else {
- if (argp->lockDevice && isLocked() && !waitForLock(argp->lock_timeout)) {
+ if (argp->lockDevice && isLocked() && !waitForLock(FLAG_WAITLOCK, argp->lock_timeout)) {
result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
}
else {
@@ -125,12 +132,14 @@ device_write_1_svc(Device_WriteParms *argp, struct svc_req *rqstp) {
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
else {
- if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
+ if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->flags, argp->lock_timeout))
result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
- printf("%s\n", argp->data.data_val);
- //result.size = argp->data.data_len;
- result.size = 1;
+#ifdef DEBUG
+ printf("got %s on link %d\n", argp->data.data_val, argp->lid);
+#endif
+ Parser_main(argp->data, 0, GPIB_and_VXI_start_query_response, NULL);
+ result.size = argp->data.data_len;
result.error = 0;
}
}
@@ -145,7 +154,7 @@ device_read_1_svc(Device_ReadParms *argp, struct svc_req *rqstp) {
#endif
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
- else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
+ else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->flags, argp->lock_timeout))
result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
result.data.data_val = "HELLO!";
@@ -164,11 +173,11 @@ device_readstb_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) {
#endif
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
- else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
+ else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->flags, argp->lock_timeout))
result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
result.error = 0;
- result.stb = 0;
+ result.stb = GPIB_and_VXI_get_STB();
}
return &result;
}
@@ -181,7 +190,7 @@ device_trigger_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) {
#endif
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
- else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
+ else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->flags, argp->lock_timeout))
result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
result.error = 0;
@@ -197,7 +206,7 @@ device_clear_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) {
#endif
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
- else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
+ else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->flags, argp->lock_timeout))
result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
result.error = 0;
@@ -213,7 +222,7 @@ device_remote_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) {
#endif
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
- else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
+ else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->flags, argp->lock_timeout))
result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
if (isLocked() && !haveLock(argp->lid))
@@ -232,7 +241,7 @@ device_local_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) {
#endif
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
- else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
+ else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->flags, argp->lock_timeout))
result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
if (isLocked() && !haveLock(argp->lid))
@@ -307,7 +316,7 @@ device_docmd_1_svc(Device_DocmdParms *argp, struct svc_req *rqstp) {
#endif
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
- else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
+ else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->flags, argp->lock_timeout))
result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
result.data_out.data_out_len = 0;