Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOError: [Errno 2] No such file or directory: '/sys/devices/virtual/gpio/gpio25/value' #4

Closed
nick-hills opened this issue Oct 5, 2013 · 1 comment

Comments

@nick-hills
Copy link

Running this stripped down test code, the subject error occurs.

!/usr/bin/python

import pifacecommon.core
import pifacecommon.interrupts
import os
import time

def print_flag(event):
print ("You pressed button" + event.pin_num)

pifacecommon.core.init()
port = pifacecommon.core.GPIOB
listener = pifacecommon.interrupts.PortEventListener(port)

listener.register(0, pifacecommon.interrupts.IODIR_ON, print_flag)

listener.activate()

results in:

Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python3.2/multiprocessing/process.py", line 267, in _bootstrap
self.run()
File "/usr/lib/python3.2/multiprocessing/process.py", line 116, in run
self._target(_self._args, *_self._kwargs)
File "/usr/lib/python3/dist-packages/pifacecommon/interrupts.py", line 207, in watch_port_events
gpio25 = open(GPIO_INTERRUPT_DEVICE_VALUE, 'r') # change to use 'with'?
IOError: [Errno 2] No such file or directory: '/sys/devices/virtual/gpio/gpio25/value'

@tompreston
Copy link
Member

You need to enable interrupts first when using just pifacecommon. I appreciate that this probably needs better documentation, I did not realise so many people were using it. Also be careful, the function enable_interrupts() is scheduled to change in the next version of pifacecommon v4.0.0. Make sure you read the change log.

#!/usr/bin/python

import pifacecommon.core
import pifacecommon.interrupts
import os
import time

def print_flag(event):
    print ("You pressed button" + event.pin_num)

pifacecommon.core.init()
port = pifacecommon.core.GPIOB

pifacecommon.interrupts.enable_interrupts()

listener = pifacecommon.interrupts.PortEventListener(port)

listener.register(0, pifacecommon.interrupts.IODIR_ON, print_flag)

listener.activate()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants