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.
To reproduce:
The offending line of code seems to be
println!("READ | 0x{:X} : {:?}", self.offset - data.len(), data);
fromread()
in theI2CRegisterMap
implementation.