On 6/04/2018 04:01, Eric S. Raymond wrote:
I have read https://www.kernel.org/doc/Documentation/i2c/dev-interface I'm working on an application that uses SMBUS to query a battery fuel gauge, the TI bq20z95, from an SBC running Linux. Normally the SBC will periodically poll the chip, and I think I understand how to make that work. (I'm using the Gobot framework.) However, the bq20z95 also sometimes issues alarms. When this happens it claims bus master status and broadcasts a message. My question is how these asynchronous transmissions can be detectible from the SBC without being confused with responses to its normal device polling. More specifically, is there a way to write a non-blocking test for whether there is a broadcast message pending on I2C/SMBUS? And what would the correct API call for reading such a message be? Please be forgiving if I'm misunderstanding the theory here, I'm new to working with these interconnect methods.
You should probably be using the sbs-battery driver for interfacing to the chip. That provides a sysfs interface etc for reading the bq20z95 attributes. Extending that where appropriate for any extended attributes you need access to. Your i2c bus driver needs to be multi master aware to handle the broadcast charge commands. They all should be... I believe those message are only relevant to a sbs charger. Do you have a sbs compliant charger interfacing to this device? -- Regards Phil