views:

70

answers:

1

I am currenlty trying to monitor my battery status through SMBus. I have a battery along with a contorl board which constantly outputs the battery status. This control board is then connected to my mother board through a I2C-USB module. I need to write some program to recognize the SMBus connection and transmit the battery status to the user. I am a beginner when it comes to dealing with smart batteries and I2C/SMBus and am somewhat lost with how to approach this problem.

Any help of suggestions would be appreciated. Thanks.

A: 

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.

Andreas Magnusson