我试图在SMBus 8.0上与CentOS设备进行通信。我已经安装了i2C工具和libi2c。正在做什么
find / -name "smbus.h" 2>/dev/null不会返回任何结果。正在运行
i2cdump 不起作用。
i2cdump 4 0x12 sp
"Error: Block read failed, return code -6"命令
i2cget 返回“错误:读取失败”
我试着自己编译一个c程序,以便从本指南后面的块读取,但是当我试图编译它时,它说
“致命错误: i2c/smbus.h:没有此类文件或目录”
yum whatprovides */smbus.h 显示内核开发的一些结果,但是安装没有帮助,smbus.h文件是空的。我如何与smbus沟通?
i2cdetect -l 显示
i2c-3 i2c DPDDC-C I2C adapter
i2c-1 i2c i915 gmbus dpc I2C adapter
i2c-4 smbus SMBus I801 adapter at f040 SMBus adapter
i2c-2 i2c i915 gmbus misc I2C adapter
i2c-0 i2c i915 gmbus dpb I2C adapter之后更新
i2cdetect -F 4输出:
Functionalities implemented by /dev/i2c-4:
I2C no
SMBus Quick Command yes
SMBus Send Byte yes
SMBus Receive Byte yes
SMBus Write Byte yes
SMBus Read Byte yes
SMBus Write Word yes
SMBus Read Word yes
SMBus Process Call no
SMBus Block Write yes
SMBus Block Read yes
SMBus Block Process Call no
SMBus PEC yes
I2C Block Write yes
I2C Block Read yesi2cdetect 4输出:
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- 08 -- -- 0b -- -- -- --
10: 10 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- -- 编辑2:我想出了我想从0x0b读取的设备。我可以使用以下方法成功地完成i2c转储:
i2cdump 4 0x0b但是,这是一个带有错误检查的smbus设备,因此正确的命令应该是:
i2cdump 4 0x0b sp但是我得到了这个命令的错误。
错误:块读取失败,返回代码-74
发布于 2020-03-23 22:43:43
欢迎来到Unix & Linux StackExchange!
为了编译使用libi2c库包的自己的程序,您需要安装相应的开发包(也就是:libi2c-devel )。
对于i2cdump和i2cget,您似乎必须指定总线号/名称和总线上的地址才能让它们做任何有用的事情。
在您的示例中,smbus是i2c-4或总线编号4。默认情况下,这些工具可能尝试使用总线号0,即i2c而不是SMBus,而该总线可能已经处于i915 GPU驱动程序的控制之下,这可能是命令失败的另一个原因。
并非所有i2c/SMBus适配器都支持所有命令。从i2cdetect -F 4开始,查看SMBus适配器支持哪些命令。输出将如下所示:
# i2cdetect -F 4
Functionalities implemented by /dev/i2c-4:
I2C no
SMBus Quick Command yes
SMBus Send Byte yes
SMBus Receive Byte yes
SMBus Write Byte yes
SMBus Read Byte yes
SMBus Write Word yes
SMBus Read Word yes
SMBus Process Call no
SMBus Block Write yes
SMBus Block Read yes
SMBus Block Process Call no
SMBus PEC yes
I2C Block Write yes
I2C Block Read yes您还可以在总线上运行设备检测,如下所示:
# i2cdetect 4
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-4.
I will probe address range 0x03-0x77.
Continue? [Y/n]
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- 08 -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- UU -- UU -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: 30 31 -- -- 34 35 -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
50: -- 51 -- 53 -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- -- 这将列出总线地址值,这些值似乎是响应总线上的一个简单命令。使用有效地址和总线命令列表,您可以开始探测总线上的各个设备。
https://unix.stackexchange.com/questions/574490
复制相似问题