ISO Example for reading/writing uart/rs-232

Thilo Schulz thilo at tjps.eu
Tue Dec 15 01:42:58 CET 2015


Hi,

On Monday 14 December 2015 22:52:02 Chris Galas wrote:
> I'm looking for an example using ev_io with a uart/rs-232 (/dev/ttyS...).

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

main()
{
	ev_io iow;
	ev_loop *mainloop;
	
	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);
	}
}

-- 
Best regards,
Thilo Schulz



More information about the libev mailing list