Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Software I2C device doesn't recognize change to ConnectionSettings.SlaveAddress for reads/writes #168
I have an I2C device with a configurable slave address. It starts with a default slave address of 127 and once I put the device into setup mode, via software, it allows it's slave address to be modified and then communicates on that new slave address from that point forward (until power is lost in which case defaults back to 127).
Using Software I2C, I am able to communicate to the device on address 127 . However, when the device has been given it's new slave address, say 1, and I change the existing Software I2C object's slave address, via ConnectionSettings.SlaveAddress, to 1 the device no longer responds on the new address.
When Reading or Writing with the new slave address I just get SlaveAddressNotAcknowledged. I've verified that the I2C device object has the new SlaveAddress.
If I create a new Software I2C object with address of 1, I am able to read and write to the device.
I was expecting that since SlaveAddress is updatable, the I2C Software object would use the new address on subsequent reads and writes. If this is not the expected behavior then I would have expected the SlaveAddress to be a read-only property.
I was hoping that I could get by with one Software I2C object and simply change the SlaveAddress since the documentation on Software I2C states "...software I2C requires more system resources..."
I am able to work around this issue by creating multiple Software I2C objects as needed however it would be nice to know if this is a bug so that when fixed I can refactor my code back to using just one Software I2C device object.
Changes to the settings having no effect is by design, see the remarks under
"...software I2C requires more system resources..." refers to reading and writing via software I2C, not a per-instance overhead. Outside of the small memory cost of each instance, multiple instances have no overhead compared to one. So feel free to create multiple.