通过 SMBus 访问/监控电池状态

发布于 2024-09-11 00:57:54 字数 222 浏览 8 评论 0原文

我目前正在尝试通过 SMBus 监控我的电池状态。

我有一个电池和一个不断输出电池状态的控制板。

然后该控制板通过 I2C-USB 模块连接到我的主板。

我需要编写一个程序来识别 SMBus 连接并将电池状态传输给用户。

在处理智能电池和 I2C/SMBus 方面,我是一个初学者,而且我对如何解决这个问题有些迷茫。

任何建议的帮助将不胜感激。谢谢。

I am currenlty trying to monitor my battery status through SMBus.

I have a battery along with a control board that constantly outputs the battery status.

This control board is then connected to my mother board through a I2C-USB module.

I need to write a program to recognize the SMBus connection and transmit the battery status to the user.

I'm a beginner when it comes to dealing with smart batteries and I2C/SMBus, and I'm somewhat lost with how to approach this problem.

Any help of suggestions would be appreciated. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

残疾 2024-09-18 00:57:54

你的问题有点欠缺。什么样的I2C-USB模块?或者说它带有 Linux 驱动程序?如果是这样,您可能不需要写一个。一个应用程序就可以了。您可以在此处了解有关 I2C 和 SMBus 的更多信息。

基本上你需要的是控制板的I2C地址(一个字节)。当您获得地址后,您(作为主机)使用其地址通过 I2C 总线向控制板发出读取命令并读取响应。如果有 I2C-USB 模块的驱动程序,这应该很简单。插入设备并 open() 设备(/dev/[i2c-usb-name],其中 [i2c-usb-name] 是设备的名称)。然后按照驱动程序实现者的指南如何通过该设备设置和发送数据(通常使用 read()/write() 或 ioctl())。以下是有关从用户空间使用 I2C 的一些附加信息: http://www.mjmwired.net /kernel/Documentation/i2c(在左侧菜单中选择主题)。

如果您必须自己编写驱动程序,Linux 设备驱动程序初学者的第一站是LDD3。读一下,读起来很愉快。

Your question is a bit lacking. What kind of I2C-USB module? Or rather does it come with a Linux driver? If it does you probably won't need to write one. An application will do. You can read more about I2C and SMBus here.

Basically what you need is the I2C address of the control board (a single byte). When you have the address you (as the master) issue read commands over the I2C bus to the control board using its address and reads the response. If there's a driver for the I2C-USB module this should be straightforward enough. Plug in the device and open() the device (/dev/[i2c-usb-name] where [i2c-usb-name] is the name of the device). Then follow the driver implementer's guide how to setup and send data over that device (typically using read()/write() or ioctl()). Here are some additional information on working with I2C from user space: http://www.mjmwired.net/kernel/Documentation/i2c (select topics in the menu on the left hand side).

If you must write the driver yourself, the first stop for a Linux device driver beginner is the LDD3. Read it, it's quite a pleasant read.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文