9 #include "../layout/dlist.h"
15 static void serial_error(OutBufferChain *ch, const char *e1, const char *e2) {
19 static OutBufferChain serial_ochain= { (char*)"serial", -1, serial_error };
21 static void *serial_exception(oop_source *evts, int fd,
22 oop_event evt, void *cl_v) {
23 die("serial port - exception");
26 static void *serial_readable(oop_source *evts, int fd,
27 oop_event evt, void *u0) {
28 events->cancel_fd(events, serial_fd, OOP_READ);
34 int main(int argc, const char **argv) {
35 oop_source_sys *sys_events;
39 if (!device) device= "/dev/ttyS0";
41 sys_events= oop_sys_new(); if (!sys_events) diee("oop_sys_new");
42 events= oop_sys_source(sys_events); assert(events);
45 r= oop_fd_nonblock(serial_fd, 1); if (r) diee("nonblock(serial_fd,1)");
46 serial_ochain.fd= serial_fd;
50 events->on_fd(events, serial_fd, OOP_READ, serial_readable, 0);
51 events->on_fd(events, serial_fd, OOP_EXCEPTION, serial_exception, 0);
52 oop_sys_run(sys_events);