rust-embedded/rust-i2cdev

smbus_read_word_data() on MockI2CDevice fails at address 0x00

tnagyzambo opened this issue · 1 comments

To reproduce:

let mut dev = MockI2CDevice::new();
dev.regmap.write_regs(0, &[0x00, 0x01]);
let _fails = dev.smbus_read_word_data(0x00); // fails with: thread 'main' panicked at 'attempt to subtract with overflow'

The offending line of code seems to be println!("READ | 0x{:X} : {:?}", self.offset - data.len(), data); from read() in the I2CRegisterMap implementation.

Thank you for noticing this. A PR fixing it would be very welcome.