I'm trying to interface a Raspberry Pi with the mini-box OpenUPS. It claims to implement the Smart Battery SMBus specifications.
I can read data from the device using the i2c_smbus_read_word_data() function as defined in the Linux Kernel docs.
So, my basic problem is this: When the device is booted for the first time, and I perform the first read, all the data is messed up. I get negative numbers, and none of it makes sense.
But, if I perform a single byte read, then all following word reads give the correct data.
It's almost as if the byte order is getting messed up in a buffer someplace, and it takes a single byte read to straighten it out. But why doesn't it work the first time?