简体   繁体   English

打开的文件太多:/dev/spidev0.0

[英]Too many open files: /dev/spidev0.0

I have been trying to read a channel by interfacing MCP3008 with Raspberry Pi zero w through SPI.我一直在尝试通过 SPI 将 MCP3008 与 Raspberry Pi 零 w 接口来读取频道。 I am using the Adafruit blinka lib to do so.我正在使用 Adafruit blinka 库来执行此操作。 After giving data for some time it shows the error [Errno 24] Too many open files: '/dev/spidev0.0'提供数据一段时间后,它显示错误[Errno 24] Too many open files: '/dev/spidev0.0'

I have written the code in Python, and implemented it in a node.我在Python写了代码,并在一个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")

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 ulimit -a

Typically this is 1024. To change this you can use通常这是 1024。要更改它,您可以使用

ulimit -n 2048 ulimit -n 2048

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM