Re: Using libev with /sys/class/gpios

2017-11-21 Thread Marc Lehmann
On Wed, Nov 22, 2017 at 01:39:13AM +, Deri James 
 wrote:
> The file /sys/class/gpio/gpio??/value is a pseudo file which reflect the 
> current 

I assume you are talking about linux here. In general, on linux, if things
work with poll or select, they also work with libev.

> The kernel 
> actually raises an interrupt

I severely doubt the kernel raises an interrupt - either the hardware
raises an interrupt or the kernel somehow notifies the application with a
signal or an I/O readyness notification.

> when the state changes and using POLLPRI |
> POLLERR with the standard poll() routine seems to work Ok.

You can't specify poll flags with libev, because libev does not normally
use poll. You also cannot specify POLLERR at all, as this is an output flag
and specifying it would be a bug. Libev will report POLLERR as a treadyness
event.

Have you tried polling with EV_READ and/or EV_WRITE? It would be a kernel
bug if POLLPRI is signalled but POLLIN isn't, as urgent read data is also
read data.

> Is it possible to do this with the libev library?

libev might be able to poll for the gpio events, but it cannot specify
custom poll flags simply because libev supports (and usually uses) other
mechanisms than poll.

If EV_READ/WRITE doesn't work, you likely can't make it work directly with
libev. You might be able to use epoll and poll the epoll fd with libev
though, if you have to use libev. epoll also doesn't support POLLPRI, but
it does support the (hopefully equivalent) EPOLLPRI.

If the fd really just signals POLLPRI but not POLLIN with poll, then you
might consider reporting this as a kernel bug.

-- 
  -==- |
  ==-- _   |
  ---==---(_)__  __   __   Marc Lehmann  +--
  --==---/ / _ \/ // /\ \/ /   p...@goof.com  |e|
  -=/_/_//_/\_,_/ /_/\_\   XX11-RIPE --+
The choice of a GNU generation   |
 |

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

Using libev with /sys/class/gpios

2017-11-21 Thread Deri James
The file /sys/class/gpio/gpio??/value is a pseudo file which reflect the 
current 
state of various hardware pins 0/1 depending on whether they are high/low. 
They are always in a "readable" state, so EV_READ is not useful. The kernel 
actually raises an interrupt when the state changes and using POLLPRI |
POLLERR with the standard poll() routine seems to work Ok.

I am using EV.pm on a Raspberry pi which has about 25 of these pins, and it 
works if I use IO::Poll, but I can't work out how to pass the POLLPRI | 
POLLERR flags as a io watcher with EV.

Is it possible to do this with the libev library?

Cheers 

Deri

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