-hostside
+realtime
hostside-old
+hostside
safety
t
layoutinfo.h
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)
serial_transmit(&pi);
ouack(ci);
}
-
-const CmdInfo toplevel_cmds[]= {
- { "pic", cmd_pic },
- { "nmra", cmd_nmra, },
- { "noop", cmd_noop },
- { 0 }
-};
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 ----------*/
* 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 */
* 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);
+}
--- /dev/null
+void vbadcmd(ParseState *ps, const char *fmt, va_list al) {
+ voerror(&ps->ci->out,fmt,al);
+}
+
-/**/
+/*
+ * daemons
+ * output buffer chains
+ */
#include <assert.h>
#include <stdlib.h>
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;
}
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)");
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));
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);
}
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) {
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 }
+};