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

spi.py OSError (9) Bad File Descriptor #16

Open
kbknapp opened this issue Apr 14, 2014 · 0 comments
Open

spi.py OSError (9) Bad File Descriptor #16

kbknapp opened this issue Apr 14, 2014 · 0 comments

Comments

@kbknapp
Copy link

kbknapp commented Apr 14, 2014

I have a function that is called when the navigation rocker is pushed to the right:

    def update_display(self, line):
        print('Updating display')
        lcd = self.__cad.lcd
        lcd.home()
        lcd.set_cursor(0, 1)
        lcd.write(' ' * pifacecad.lcd.LCD_WIDTH)
        lcd.set_cursor(0, 1)
        print('Writing {}'.format(line))
        lcd.write(line)

The switch event listener is set up like so:

# ROCKER_RIGHT = 7
listener = pifacecad.SwitchEventListener(chip=cad)
listener.register(ROCKER_RIGHT, pifacecad.IODIR_ON, platypi.next_option)
listener.activate()

On the fifth (5th) time I press the rocker right I ALWAYS get the following error:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 921, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 869, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.4/site-packages/pifacecommon/interrupts.py", line 339, in handle_events
    function(event)
  File "platypi.py", line 58, in next_option
    self.update_display(os.path.basename(self.__options[self.__index]))
  File "platypi.py", line 78, in update_display
    lcd.home()
  File "/usr/lib/python3.4/site-packages/pifacecad/lcd.py", line 251, in home
    self.send_command(LCD_RETURNHOME)  # set cursor position to zero
  File "/usr/lib/python3.4/site-packages/pifacecad/lcd.py", line 411, in send_command
    self.control_port.register_select_pin.value = 0
  File "/usr/lib/python3.4/site-packages/pifacecommon/mcp23s17.py", line 358, in value
    self.chip.write_bit(v, self.bit_num, self.address)
  File "/usr/lib/python3.4/site-packages/pifacecommon/mcp23s17.py", line 201, in write_bit
    old_byte = self.read(address)
  File "/usr/lib/python3.4/site-packages/pifacecommon/mcp23s17.py", line 143, in read
    return self._pyver_read(address)
  File "/usr/lib/python3.4/site-packages/pifacecommon/mcp23s17.py", line 147, in _py3read
    op, addr, data = self.spisend(bytes((ctrl_byte, address, 0)))
  File "/usr/lib/python3.4/site-packages/pifacecommon/spi.py", line 74, in spisend
    ioctl(self.fd, SPI_IOC_MESSAGE(1), transfer)
OSError: [Errno 9] Bad file descriptor

Just for curiosity sake, I added a print(self.fd) in spi.py which prints "4"

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

1 participant