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) {
33 int main(int argc, const char **argv) {
34 oop_source_sys *sys_events;
38 if (!device) device= "/dev/ttyS0";
40 sys_events= oop_sys_new(); if (!sys_events) diee("oop_sys_new");
41 events= oop_sys_source(sys_events); assert(events);
44 r= oop_fd_nonblock(serial_fd, 1); if (r) diee("nonblock(serial_fd,1)");
45 serial_ochain.fd= serial_fd;
49 events->on_fd(events, serial_fd, OOP_READ, serial_readable, 0);
50 events->on_fd(events, serial_fd, OOP_EXCEPTION, serial_exception, 0);
51 oop_sys_run(sys_events);