首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SMBus通讯不工作。埋伏.h

SMBus通讯不工作。埋伏.h
EN

Unix & Linux用户
提问于 2020-03-23 18:57:50
回答 1查看 2.4K关注 0票数 1

我试图在SMBus 8.0上与CentOS设备进行通信。我已经安装了i2C工具和libi2c。正在做什么

代码语言:javascript
复制
find / -name "smbus.h" 2>/dev/null

不会返回任何结果。正在运行

代码语言:javascript
复制
i2cdump 

不起作用。

代码语言:javascript
复制
i2cdump 4 0x12 sp 
"Error: Block read failed, return code -6"

命令

代码语言:javascript
复制
i2cget 

返回“错误:读取失败”

我试着自己编译一个c程序,以便从本指南后面的块读取,但是当我试图编译它时,它说

“致命错误: i2c/smbus.h:没有此类文件或目录”

代码语言:javascript
复制
yum whatprovides */smbus.h 

显示内核开发的一些结果,但是安装没有帮助,smbus.h文件是空的。我如何与smbus沟通?

代码语言:javascript
复制
i2cdetect -l 

显示

代码语言:javascript
复制
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

在telcoM的答复

之后更新

i2cdetect -F 4输出:

代码语言:javascript
复制
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输出:

代码语言:javascript
复制
     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转储:

代码语言:javascript
复制
i2cdump 4 0x0b

但是,这是一个带有错误检查的smbus设备,因此正确的命令应该是:

代码语言:javascript
复制
i2cdump 4 0x0b sp

但是我得到了这个命令的错误。

错误:块读取失败,返回代码-74

EN

回答 1

Unix & Linux用户

发布于 2020-03-23 22:43:43

欢迎来到Unix & Linux StackExchange!

为了编译使用libi2c库包的自己的程序,您需要安装相应的开发包(也就是:libi2c-devel )。

对于i2cdumpi2cget,您似乎必须指定总线号/名称和总线上的地址才能让它们做任何有用的事情。

在您的示例中,smbus是i2c-4或总线编号4。默认情况下,这些工具可能尝试使用总线号0,即i2c而不是SMBus,而该总线可能已经处于i915 GPU驱动程序的控制之下,这可能是命令失败的另一个原因。

并非所有i2c/SMBus适配器都支持所有命令。从i2cdetect -F 4开始,查看SMBus适配器支持哪些命令。输出将如下所示:

代码语言:javascript
复制
# 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

您还可以在总线上运行设备检测,如下所示:

代码语言:javascript
复制
# 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: -- -- -- -- -- -- -- --       

这将列出总线地址值,这些值似乎是响应总线上的一个简单命令。使用有效地址和总线命令列表,您可以开始探测总线上的各个设备。

票数 1
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/574490

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档