Hi,

wrote last source off the top of my head and the declaration of fd got lost 
while reshuffeling. This should work for real.

#define EV_COMPAT3 0

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <ev.h>

void somecallback(ev_loop *loop, ev_io *iowatch, int revents)
{
        write(iowatch->fd, "booya", 5);
        ev_io_stop(loop, iowatch);
}

main()
{
        ev_io iow;
        ev_loop *mainloop;
        int fd;

        fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NONBLOCK);

        if(fd >= 0)
        {
                mainloop = ev_default_loop(EVFLAG_AUTO);
                ev_io_init(&iow, somecallback, fd, EV_WRITE);
                ev_io_start(mainloop, &iow);
                ev_run(mainloop, 0);
                close(fd);
        }
}


_______________________________________________
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev

Reply via email to