python - 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()
解决方案
推荐阅读
- c++ - 当抽象出一个类时,我的 OpenGL 顶点数组不再起作用
- python - 我们可以设置可以在会话中修改的模块级属性吗
- r - 访问不存在的列表元素时如何强制出错或“NULL”?
- java - Firebase Admin SDK Messaging 如何处理 canonical_ids?
- outlook - 在 MS Outlook 插件中设置收件人
- android - API 28 (Pie) 设备上的 Android 应用程序在尝试连接到 AWS 上的 Parse Server 时返回 i/o 异常
- php - Symfony 和 API 平台 - 通过 slug 或 userToken 或任何其他不同于 ID 的字段检索数据
- llvm - LLVM:如何使用 Compiler-RT 的调试符号进行编译
- python - 使用欧拉角/矩阵在 3d 空间中旋转?
- python - 如何通过 for 循环迭代器将字符串中的空格相乘?