[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] RE: epoll fd in libevent



Hallo libevent users!

Sorry for all the noise but I could make it work correctly after configuring an edge on the GPIO line!

Thanks for all the job!

Guy Morand

-----Original Message-----
From: owner-libevent-users@xxxxxxxxxxxxx [mailto:owner-libevent-users@xxxxxxxxxxxxx] On Behalf Of Morand, Guy
Sent: Dienstag, 25. August 2015 11:41
To: libevent-users@xxxxxxxx
Subject: [Libevent-users] epoll fd in libevent

Hallo libevent developers,

I want to monitor GPIO lines under Linux and I'm using libevent. As I understand, for portability issues, it is not possible to monitor GPIOs with libevent because the "exception" event is not cross platform.

I saw in a thread of the libevent mailing list that it would be possible to create an epoll and register the file descriptor in libevent: 
http://archives.seul.org/libevent/users/Apr-2012/msg00026.html

I tried this solution but the problem is that I only get the "POLLPRI" event once at startup, despite I register the epoll fd in libevent with "EV_READ | EV_PERSIST".

Some code talks more than too many explanation, here is how I register the GPIO in epoll:
int EPollEventLoop::addExceptionHandler(libds::IIoHandler& handler)
{
    struct epoll_event event;

    // Init must be called
    assert(m_epollFd >= 0);

    // Add to epoll
    event.data.fd = handler.getIoHandle();
    event.events = EPOLLPRI;    
    if (epoll_ctl(m_epollFd, EPOLL_CTL_ADD, handler.getIoHandle(), &event) != 0)
    {
        ILog_msg(NULL, LOG_LEVEL_ERR, "Cannot add event to epoll %s", strerror(errno));
        return -1;
    }

    return 0;
}

I'm wondering if this solution is supposed to work or if I'm missing something like edge/level triggered. Anyone could achieve this?

Kind regards,

Guy Morand
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.