This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] SK-AM62P-LP:GPIOD 的版本已过期或版本错误

Guru**** 2553260 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1558528/sk-am62p-lp-version-of-gpiod-is-out-of-date-or-wrong-version

器件型号:SK-AM62P-LP


工具/软件:

我正在为光学编码器编写一些 python 代码、但我收到了一个不明白的错误。 我能否解释一下为什么会出现此错误? 我已对其进行了研究、两种变体都应有效。

我的代码:

import TI.GPIO as GPIO
import gpiod
import time

# Update these according to your board's GPIO chip and line numbers
CHIP_NAME = '/dev/gpiochip0'
PIN_A = 13  # Replace with actual GPIO line number for A
PIN_B = 16  # Replace with actual GPIO line number for B

chip = gpiod.Chip(CHIP_NAME)
line_a = chip.get_line_info(PIN_A)
line_b = chip.get_line_info(PIN_B)

# Request lines as inputs with bias disabled
config = gpiod.LineRequest(consumer="rotary-encoder", request_type=gpiod.LineRequest.DIRECTION_INPUT)
#config.consumer = "rotary-encoder"
#config.request_type = gpiod.LineRequest.DIRECTION_INPUT

我的错误:

root@am62pxx-EVM:~/ti-am62p# python3 ai_test_chcp.py
回溯(最近一次呼叫):
文件“/root/ti-am62p/ai_test_chcp.py、第 15 行、在中
config = gpiod.LineRequest (Consumer=“旋转编码器“、request_type=gpiod.LineRequest.direction_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^μ s
AttributeError:类型对象“LineRequest"没有“没有属性“Idrection_input"</s>“

我还尝试了:

    chip = gpiod.Chip('/dev/gpiochip0')
    lineA = chip.get_line_info(LINE_A)
    lineB = chip.get_line_info(LINE_B)
    config = gpiod.LineRequest()
    config.consumer - "rotary"
    config.request_type = gpiod.LineRequest.DIRECTION_INPUT
    config.event_flags = gpiod.LineRequest.EVENT_BOTH_EDGES

我的错误:

root@am62pxx-EVM:~/ti-am62p# python3 test_chcp.py
回溯(最近一次呼叫):
文件“/root/ti-am62p/test_chcp.py、第 74 行、在中
main()
文件/root/ti-am62p/test_chcp.py、第 41 行、位于 main 中
配置= gpiod.LineRequest ()
^^^^^^^^^^^^^^^^^^^μ s
类型错误: LineRequest.__init__() 缺少 1 个必需的位置参数:'req'