Too many open files: /dev/spidev0.0

146 views Asked by At

I have been trying to read a channel by interfacing MCP3008 with Raspberry Pi zero w through SPI. I am using the Adafruit blinka lib to do so. After giving data for some time it shows the error [Errno 24] Too many open files: '/dev/spidev0.0'

I have written the code in Python, and implemented it in a node.

import wiringpi
from time import sleep
wiringpi.wiringPiSetup()
import busio
import digitalio
import board

import adafruit_mcp3xxx.mcp3008 as MCP
from adafruit_mcp3xxx.analog_in import AnalogIn

class Readspi(Node):
    def execute(self):
        try:
            input_io = self.get_input_params()
            clock = int(input_io['clock'])
            miso = int(input_io["miso"])
            mosi = int(input_io["mosi"])
            channel = int(input_io['channel'])
            spi = busio.SPI(clock, mosi, miso)
            cs = digitalio.DigitalInOut(board.D5)
            mcp = MCP.MCP3008(spi, cs)
            temp_value = AnalogIn(mcp, channel)
            new_value = temp_value.value
            print(type(new_value), " ", new_value)
            spi.deinit()
        except Exception as exception:
            self.set_next_node_params([str(exception), ])
            print("fail")
1

There are 1 answers

0
Robert On

I guess your not closing your files properly and you then run into the open files limit You can check your current limit via

ulimit -a

Typically this is 1024. To change this you can use

ulimit -n 2048