chiark / gitweb /
realtime compiles and links now
authorian <ian>
Fri, 5 May 2006 00:25:03 +0000 (00:25 +0000)
committerian <ian>
Fri, 5 May 2006 00:25:03 +0000 (00:25 +0000)
hostside/.cvsignore
hostside/Makefile
hostside/commands.c
hostside/daemons.h
hostside/eventhelp.c
hostside/multiplex.c [new file with mode: 0644]
hostside/obc.c
hostside/realtime.c
hostside/startup.c

index e285fdd2f71cee71005a66238d66069b2f505ff3..7536abfbea1baf2342bcaa6d46d14f9ba2a82f20 100644 (file)
@@ -1,5 +1,6 @@
-hostside
+realtime
 hostside-old
+hostside
 safety
 t
 layoutinfo.h
index 0ac0a63f1b15fa387f1c081b7e49ffa812f6d025..9239920ccc182fbb2cf58eed8d8fac1e02e98457 100644 (file)
@@ -14,9 +14,9 @@ all:          $(TARGETS)
 hostside-old:  serialio.o nmra.o main.o encode.o utils.o
                $(LINK)
 
-realtime:      realtime.o startup.o cdumgr.o           \
-                cmdinput.o                             \
-                utils.o serialio.o auproto-pic.o       \
+realtime:      realtime.o startup.o cdumgr.o                   \
+                cmdinput.o obc.o eventhelp.o                   \
+                utils.o serialio.o parseutils.o auproto-pic.o  \
                 __oop-read-copy.o -loop
                $(LINK)
 
index 26ee20dd6ec51c69cac27bf89878f738a306ce2c..2dccc253ba76740ccbd0fe882bb028d260dba2ff 100644 (file)
@@ -184,10 +184,3 @@ static void cmd_pic(ParseState *ps, const CmdInfo *ci) {
   serial_transmit(&pi);
   ouack(ci);
 }
-
-const CmdInfo toplevel_cmds[]= {
-  { "pic",        cmd_pic         },
-  { "nmra",       cmd_nmra,       },
-  { "noop",       cmd_noop        },
-  { 0 }
-};
index 205b66a672b8b39858616745e10ea7a95037951c..341f62e713ad0add6c298306f69b9850fcb17716 100644 (file)
@@ -38,6 +38,8 @@ void ovprintf(OutBufferChain *ch, const char *fmt, va_list al)
 void oprintf(OutBufferChain *ch, const char *msg, ...)
      __attribute__((format(printf,2,3)));
 void owrite(OutBufferChain *ch, const char *data, int l);
+void voerror(OutBufferChain *ch, const char *fmt, va_list al)
+     __attribute__((format(printf,2,0)));
 
 /*---------- from cmdinput.c ----------*/
 
@@ -71,7 +73,7 @@ struct TimeoutEvent {       /* Undefined   Idle      Running     set by   */
      * and then callback member is read and the function called
      */
 
-void toev_init(TimeoutEvent*);    /* B -> I */
+void toev_init(TimeoutEvent*);    /* U -> I */
 void toev_start(TimeoutEvent*);   /* IR -> R; reads duration */
   /* if duration is -1 then is same as toev_stop */
 void toev_stop(TimeoutEvent*);    /* IR -> I */
index 8b3dd054ff8a23a8067b55374a6f3afc8aa74905..44712407c27757f0b660b237e1ca748931dc3be4 100644 (file)
@@ -3,7 +3,36 @@
  * helpers for event handling
  */
 
+#include <assert.h>
+#include <limits.h>
+
 #include "daemons.h"
 
 oop_source *events;
 
+static void *toev_callback(oop_source *source, struct timeval tv, void *t_v) {
+  TimeoutEvent *toev= t_v;
+  toev->running= 0;
+  toev->callback(toev);
+  return OOP_CONTINUE;
+}
+
+void toev_init(TimeoutEvent *toev) { toev->running= 0; }
+
+void toev_start(TimeoutEvent *toev) {
+  toev_stop(toev);
+  if (toev->duration==-1) return;
+  toev->running= 1;
+  mgettimeofday(&toev->abs);
+  assert(toev->duration < INT_MAX/1000);
+  toev->abs.tv_usec += toev->duration * 1000;
+  toev->abs.tv_sec += toev->abs.tv_usec / 1000000;
+  toev->abs.tv_usec %= 1000000;
+  events->on_time(events, toev->abs, toev_callback, toev);
+}
+
+void toev_stop(TimeoutEvent *toev) {
+  if (!toev->running) return;
+  toev->running= 0;
+  events->cancel_time(events, toev->abs, toev_callback, toev);
+}
diff --git a/hostside/multiplex.c b/hostside/multiplex.c
new file mode 100644 (file)
index 0000000..1d30794
--- /dev/null
@@ -0,0 +1,4 @@
+void vbadcmd(ParseState *ps, const char *fmt, va_list al) {
+  voerror(&ps->ci->out,fmt,al);
+}
+
index 63547a065d968d21b3c76c788f3d195f7c58fac7..7154d8341cb4cf0347a2886b70adc764764fcb7e 100644 (file)
@@ -1,4 +1,7 @@
-/**/
+/*
+ * daemons
+ * output buffer chains
+ */
 
 #include <assert.h>
 #include <stdlib.h>
@@ -15,12 +18,6 @@ struct OutBuffer {
   int l;
 };
 
-void vbadcmd(ParseState *ps, const char *fmt, va_list al) {
-  oprintf(&ps->ci->out,"error ");
-  ovprintf(&ps->ci->out,fmt,al);
-  owrite(&ps->ci->out,"\n",1);
-}
-
 static void *writeable(oop_source *evts, int fd,
                       oop_event evt, void *ch_v) {
   OutBufferChain *ch= ch_v;
@@ -62,6 +59,7 @@ static void addlink(OutBufferChain *ch, OutBuffer *ob) {
 }
 
 void obc_init(OutBufferChain *ch) {
+  int r;
   ch->done_of_head= 0;
   r= oop_fd_nonblock(ch->fd, 1);
   if (r) diee("nonblock(OutBufferChain->fd,1)");
@@ -83,6 +81,12 @@ void oprintf(OutBufferChain *ch, const char *msg, ...) {
   va_end(al);
 }
 
+void voerror(OutBufferChain *ch, const char *fmt, va_list al) {
+  oprintf(ch,"error ");
+  ovprintf(ch,fmt,al);
+  owrite(ch,"\n",1);
+}
+
 void owrite(OutBufferChain *ch, const char *data, int l) {
   OutBuffer *ob;
   ob= mmalloc(sizeof(*ob));
index 7d2b7cd27e0b9a3f9a48bcf43a15e68fdae22965..e42e0763ab603491d0a8a6d8538336a4998cb722 100644 (file)
@@ -52,6 +52,10 @@ void oupicio(const char *dirn, const PicInsnInfo *pii, int objnum) {
     oprintf(UPO, "picio %s %s %u\n", dirn, pii->name, objnum);
 }
 
+void vbadcmd(ParseState *ps, const char *fmt, va_list al) {
+  voerror(UPO,fmt,al);
+}
+
 static void obc_error(OutBufferChain *ch, const char *e1, const char *e2) {
   comms_error(ch->desc, e1, e2);
 }
index f9fd986ba9299e41168cca9d22c95388a614acb6..bc2c0bf092a43a345069a111f6a9ef0e368baa50 100644 (file)
@@ -177,6 +177,11 @@ void on_pic_wtimeout(const PicInsnInfo *pii, const PicInsn *pi, int objnum) {
   oprintf(UPO, "warning watchdog \"PIC watchdog timer triggered\"\n");
 }
 
+void on_pic_hello(const PicInsnInfo *pii, const PicInsn *pi, int objnum)
+  { abort(); }
+void on_pic_aaargh(const PicInsnInfo *pii, const PicInsn *pi, int objnum)
+  { abort(); }
+
 /*---------- fixme move these to where they want to go ----------*/
 
 void on_pic_nmradone(const PicInsnInfo *pii, const PicInsn *pi, int objnum) {
@@ -195,3 +200,12 @@ void on_pic_detect1(const PicInsnInfo *pii, const PicInsn *pi, int objnum) {
 void abandon_run(void) {
   /* fixme do something here */
 }
+
+const CmdInfo toplevel_cmds[]= {
+#if 0
+  { "pic",        cmd_pic         },
+  { "nmra",       cmd_nmra,       },
+  { "noop",       cmd_noop        },
+#endif
+  { 0 }
+};