nmra encode movpos rtprio \
../layout/ours.layout-data
+LIBOOP_OBJS= __oop-read-copy.o -loop
+
REALTIME_CORE_OBJS= $(addsuffix .o, $(REALTIME_CORE))
-realtime: $(REALTIME_CORE_OBJS) \
- __oop-read-copy.o -loop -lm
+realtime: $(REALTIME_CORE_OBJS) $(LIBOOP_OBJS) -lm
$(LINK)
proto-expanded: ../cebpic/README.protocol
gui-plan-bot: gui-plan-%: gui-plan.o utils.o parseutils.o obc.o \
../layout/ours.dgram-%.plandata.o \
../layout/ours.layout-data.o \
- __oop-read-copy.o -loop
+ $(LIBOOP_OBJS)
$(LINK) -L/usr/X11R6/lib -lXpm -lX11
auproto-pic.c auproto-pic.h: auproto-%: \
./$^ >$@.new
cmp $@ $@.new || mv -f $@.new $@
-evdev-manip: evdev-manip.o utils.o
+evdev-manip: evdev-manip.o utils.o $(LIBOOP_OBJS)
safety: safety.o utils.o trackloc.o ../layout/ours.layout-data.o
$(LINK)
#include "common.h"
+#include <oop-read.h>
#include <poll.h>
#include <sys/fcntl.h>
typedef struct {
void (*event)(Device *d, const struct input_event *ie);
+ void (*died)(Device *d, int revents, int readr, int readc, int e)
+ __attribute__((noreturn));
void (*mainloop)(void);
} ModeInfo;
remain;
p+=r, remain-=r) {
r= read(d->fd, &ie, remain);
- if (r<0) {
- if (errno==EINTR) continue;
- diee("%s: error reading", d->path);
- }
- if (r==0)
- die("%s: eof ?!", d->path);
+ if (r<=0) { mode->died(d, POLLIN, r, -1, errno); abort(); }
assert(r <= remain);
}
if (ie.type == EV_SYN) {
mflushstdout();
}
+static void dump_died(Device *d, int revents, int readr, int readc, int e)
+ __attribute__((noreturn));
+static void dump_died(Device *d, int revents, int readr, int readc, int e) {
+ printf("device-terminated %s %#x ", d->path, revents);
+ if (readr<0) printf("err %s", strerror(e));
+ else if (readr==0) printf("eof");
+ else printf("%#x",readc);
+ printf("\n");
+ mflushstdout();
+ exit(0);
+}
+
static void mainloop(void) {
struct pollfd *polls;
int i, r;
assert(r>0);
for (i=0; i<ndevices; i++) {
- if (polls[i].revents & ~POLLIN)
- die("device %s (fd %d) gave unexpected poll revent %#x",
- devices[i].path, devices[i].fd, polls[i].revents);
+ if (polls[i].revents & ~POLLIN) {
+ unsigned char dummy;
+ r= oop_fd_nonblock(polls[i].fd, 1);
+ if (r) diee("nonblock %s during poll unepxected %#x",
+ devices[i].path, polls[i].revents);
+ r= read(polls[i].fd, &dummy,1);
+ mode->died(&devices[i], polls[i].revents, r, dummy, errno);
+ abort();
+ }
if (polls[i].revents)
process_device(&devices[i]);
}
}
}
-static const ModeInfo mode_dump= { dump_event, mainloop };
+static const ModeInfo mode_dump= { dump_event, dump_died, mainloop };
static void getdevice(const char *path) {
int r;