Skip to content

Non blocking interrupt #23

@ladecadence

Description

@ladecadence

Similar libraries for GPIO support in other languages (Python RPi.GPIO, WiringPi, etc), provide a background thread for interrupt detection, and callback attaching. For example in python:

RPi.GPIO runs a second thread for callback functions. This means that callback functions can be run at the same time as your main program, in immediate response to an edge. For example:

def my_callback(channel):
    print('This is a edge event callback function!')
    print('Edge detected on channel %s'%channel)
    print('This is run in a different thread to your main program')

GPIO.add_event_detect(channel, GPIO.RISING, callback=my_callback)  # add rising edge detection

I know this is difficult to do in Rust with all the safety, ownership and the like, but that will be great to have.

Activity

posborne

posborne commented on Nov 30, 2016

@posborne
Member

This wouldn't be too difficult with a thread, but that involves a thread, of course. There have been discussions about integration the Gpio poll functionality with mio or other async frameworks, although that is a somewhat different concern than a easy-to-use callback interface.

Looking at RPi.GPIO, they use a thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @posborne@ladecadence

        Issue actions

          Non blocking interrupt · Issue #23 · rust-embedded/rust-sysfs-gpio