]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
update
authorhadaq <hadaq>
Tue, 19 Oct 2010 22:12:17 +0000 (22:12 +0000)
committerhadaq <hadaq>
Tue, 19 Oct 2010 22:12:17 +0000 (22:12 +0000)
trbnetd/server/Makefile
trbnetd/server/trbnetd.c
trbnetd/trbrpc.x

index 17fd80b4bc77b0142f595378098538b057197172..f55b6cc2da9d8d2fdf02b6c1ddd2a2aa88ee4860 100644 (file)
@@ -62,12 +62,6 @@ ARFLAGS = -srv
        $(LD) -shared -O $^ -o $@
        @echo DONE!
 
-# RPCGEN
-%.h: %.x
-       rpcgen -N -M $^
-
-       rpcgen -N -M $^ 
-
 # ------------ Targets -------------------------------------------------
 
 .PHONY: all
@@ -110,4 +104,4 @@ trbrpc_xdr.c:
        ln -s ../trbrpc_xdr.c
 
 rpcserver.c:
-       rpcgen -N -m -M ../trbrpc.x > ./rpcserver.c     
\ No newline at end of file
+       rpcgen -N -m -M ../trbrpc.x > ./rpcserver.c     
index 9c33b723be614cbb87f2e9b13b09b47577ee2392..c51cf7a08efdc6ea83bb70b7d254ef0f85179174 100644 (file)
@@ -6,13 +6,14 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <unistd.h>
+#include <libgen.h>
+#include <signal.h>
 
 #include <trbnet.h>
 #include <trberror.h>
 
 #include "trbrpc.h"
 
-
 int trbnetrpcprog_1_freeresult(SVCXPRT * transp,
                                xdrproc_t xdr_result, caddr_t result)
 {
@@ -163,7 +164,6 @@ bool_t read_uid_1_svc(uint16_t trb_address,
                       struct svc_req* rqstp)
 {
   int status;
-
   /* allocate buffer memory */
   retVal->data.Buffer_val = (uint32_t *) malloc(sizeof(uint32_t) * dsize);
   if (retVal->data.Buffer_val == NULL) {
@@ -176,7 +176,6 @@ bool_t read_uid_1_svc(uint16_t trb_address,
   retVal->status.retVal = status;
   retVal->data.Buffer_len = status == -1 ? 0 : status;
   copyStatus(&retVal->status);
-
   return TRUE;
 }
 
@@ -323,15 +322,58 @@ bool_t register_modify_1_svc(uint16_t trb_address,
 
 void trbnetrpcprog_1(struct svc_req *rqstp, register SVCXPRT * transp);
 
+
+/* ------ MAIN ---------------------------------------------------------- */
+
+void usage(const char *progName)
+{
+  fprintf(stdout, "Usage: %s [-h] [-f]\n", progName);
+  fprintf(stdout, "Options:\n");
+  fprintf(stdout, "  -h    give this help\n");
+  fprintf(stdout, "  -f    execute as foreground process\n");
+}
+
 static pid_t myPid = -1;
 
+static void sigHandler(int sig)
+{
+  if (sig == SIGTERM) fprintf(stderr, "caught SIGTERM\n");
+  if (sig == SIGINT) fprintf(stderr, "caught SIGINT\n");
+
+  exit(128 + sig);
+}
+
+
+
 int main(int argc, char **argv)
 {
-  int daemonMode = 1;
   register SVCXPRT *transp;
+  int daemonMode = 1;
+  int opt;
+  
+  optind = 1;
+  while ((opt = getopt(argc, argv, "+hfd:")) != -1) {
+    switch (opt) {
+    case '?':
+      usage(basename(argv[0]));
+      return -1;
+    case 'h':
+      usage(basename(argv[0]));
+      return 0;
+    case 'f':
+      daemonMode = 0;
+      break;
+    case 'd':
+      trb_debug = strtoul(optarg, NULL, 0);
+      break;
+
+    default:
+      break;
+    }
+  }
   
-  if ((argc >= 2) && (strcmp(argv[1], "-f") == 0))
-    daemonMode = 0;
+  signal(SIGINT, sigHandler);
+  signal(SIGTERM, sigHandler);
 
   pmap_unset(TRBNETRPCPROG, TRBNETRPCVERS);
 
index 0f620bfa8e36e910c7469040be588fe28f580353..2a406782f01ea48e088bae15d4a098426377da98 100644 (file)
@@ -1,3 +1,4 @@
+
 /* RPC interface definitions of the remote trbnet functions */
 
 typedef uint32_t Buffer<>; 
@@ -25,69 +26,69 @@ program TRBNETRPCPROG {
 
     RetVal REGISTERTIME_READ(uint16_t, 
                              uint16_t, 
-                             unsigned int) = 16;
+                             unsigned int) = 2;
 
     RetVal REGISTER_READ_MEM(uint16_t, 
                                 uint16_t, 
                                 uint8_t, 
                                 uint16_t,
-                                unsigned int) = 2;
+                                unsigned int) = 3;
 
     RetVal REGISTERTIME_READ_MEM(uint16_t, 
                                  uint16_t, 
                                  uint8_t, 
                                  uint16_t,
-                                 unsigned int) = 17;
+                                 unsigned int) = 4;
   
     Status REGISTER_WRITE(uint16_t, 
                           uint16_t, 
-                          uint32_t) = 3;
+                          uint32_t) = 5;
     
     Status REGISTER_WRITE_MEM(uint16_t, 
                               uint16_t, 
                               uint8_t, 
-                              Buffer) = 4;
+                              Buffer) = 6;
     
     RetVal READ_UID(uint16_t, 
-                    unsigned int) = 5;
+                    unsigned int) = 7;
 
     Status SET_ADDRESS(uint64_t,
                        uint8_t,
-                       uint16_t) = 6;
+                       uint16_t) = 8;
 
     Status SEND_TRIGGER(uint8_t,
                         uint32_t,
                         uint8_t,
-                        uint16_t) = 7;
+                        uint16_t) = 9;
 
     Status SEND_TRIGGER_RICH(uint8_t,
                              uint8_t,
                              uint32_t,
                              uint8_t,
-                             uint16_t) = 8;
+                             uint16_t) = 10;
     
     RetVal IPU_DATA_READ(uint8_t,
                          uint32_t,
                          uint8_t,
                          uint16_t,
-                         unsigned int) = 9;
+                         unsigned int) = 11;
     
-    RetVal FPGA_REGISTER_READ(uint16_t) = 10;
+    RetVal FPGA_REGISTER_READ(uint16_t) = 12;
     
     Status FPGA_REGISTER_WRITE(uint16_t,
-                               uint32_t) = 11;
+                               uint32_t) = 13;
     
-    Status TRB_FIFO_FLUSH(uint8_t) = 12;
+    Status TRB_FIFO_FLUSH(uint8_t) = 14;
 
-    Status NETWORK_RESET(void) = 13;
+    Status NETWORK_RESET(void) = 15;
 
-    Status COM_RESET(void) = 14;
+    Status COM_RESET(void) = 16;
 
     Status REGISTER_MODIFY(uint16_t, 
                            uint16_t, 
                            int,
                            uint32_t,
-                           uint32_t) = 15;
+                           uint32_t) = 17;
   } = 1;
 } = 0x20000099;