You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I triggered one rising edge, the callback executed once, as expected. When I triggered two rising edges sequentially, the callback executed twice. But when I triggered more then two rising edges sequentially, the callback is just executed just twice.
I encountered this behaviour in the implementation of Pin.wait_edge (It's more than likely that this behaviour occurs in the other implementations of wait_edge:
defwait_edge(self,fd,callback,debouncingtime):
debouncingtime=debouncingtime/1000.0# converto in milliseconditimestampprec=time.time()
counter=0po=select.epoll()
po.register(fd,select.EPOLLET)
whileTrue:
events=po.poll()
timestamp=time.time()
if (timestamp-timestampprec>debouncingtime) andcounter>0:
callback()
counter=counter+1timestampprec=timestamp
po.poll blocks the loop until a rising egde occur. Then it excutes the callback. If during the excuting one or more rising edges occur, po.poll will not block the very first next run of the while loop. It seems that the po object (which is an epoll object) 'buffers' one edge event and therefore is does not block.
Suggested soluction:
On edge, but before the execution of the callback, the polling for events should be disabled and after the execution should be re-enabled. This will stop polling during the execution of the callback and will not 'buffer' another event.
whileTrue:
events=po.poll()
# Disable polling here.timestamp=time.time()
if (timestamp-timestampprec>debouncingtime) andcounter>0:
callback()
# Enable polling here again.counter=counter+1timestampprec=timestamp
The text was updated successfully, but these errors were encountered:
kevba
added a commit
to Appeltabak/ablib
that referenced
this issue
Feb 14, 2015
I encountered strange behaviour on a pin when a rising edge occured. I set a new rising edge on a pin with the following callback:
When I triggered one rising edge, the callback executed once, as expected. When I triggered two rising edges sequentially, the callback executed twice. But when I triggered more then two rising edges sequentially, the callback is just executed just twice.
I encountered this behaviour in the implementation of Pin.wait_edge (It's more than likely that this behaviour occurs in the other implementations of
wait_edge
:po.poll
blocks the loop until a rising egde occur. Then it excutes the callback. If during the excuting one or more rising edges occur,po.poll
will not block the very first next run of the while loop. It seems that thepo
object (which is an epoll object) 'buffers' one edge event and therefore is does not block.Suggested soluction:
On edge, but before the execution of the callback, the polling for events should be disabled and after the execution should be re-enabled. This will stop polling during the execution of the callback and will not 'buffer' another event.
The text was updated successfully, but these errors were encountered: