首页 > 解决方案 > Raspberry Pi spidev 自动在使用中

问题描述

我将使用带有 RFID 阅读器(RFID-RC522)的树莓派。我写了一个工作 python 程序,它在我的 pi3+ 上工作。当我启动我的 Pi4 时,我无法使用该程序。所以我正在寻找spi:

lsmod | grep spi

当我启动 Pi3+ 时:

spidev       20480 0
spi_bcm2835  20480 0

在我的 Pi4(具有相同设置)上,我得到:

spidev       20480 2
spi_bcm2835  24576 0

所以有一个频道正在使用,我不知道如何找出问题所在。

我希望你能帮助我。

程序:


import RPi.GPIO as gpio
from mfrc522 import SimpleMFRC522
import time
CardReader = SimpleMFRC522()
print ('Scanning for a card..')
print ('to cancel press ctrl+c')

try:
     while True:
        id, text = CardReader.read()
        file = open ("../../ftp/files/karte.txt", "w")
        print (id)
        print (text)
        name = repr(text)
        file.write(str(id) + '\n' + text + '\n')
        file.close()
        print ('Successfully read')
        time.sleep(2)

finally:
    gpio.cleanup()

标签: pythonraspberry-pispi

解决方案


推荐阅读