File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ Versioning](https://semver.org/spec/v2.0.0.html).
99## [ Unreleased]
1010
1111- Derived common traits for public types.
12+ - Fixed incrementing offset after a read with a ` MockI2CDevice ` .
1213
1314## [ v0.6.0] - 2023-08-03
1415
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ impl I2CRegisterMap {
4545 fn read ( & mut self , data : & mut [ u8 ] ) -> I2CResult < ( ) > {
4646 let len = data. len ( ) ;
4747 data. clone_from_slice ( & self . registers [ self . offset ..( self . offset + len) ] ) ;
48+ self . offset += data. len ( ) ;
4849 println ! ( "READ | 0x{:X} : {:?}" , self . offset - data. len( ) , data) ;
4950 Ok ( ( ) )
5051 }
@@ -157,3 +158,10 @@ where
157158 Ok ( messages. len ( ) as u32 )
158159 }
159160}
161+
162+ #[ test]
163+ fn check_read_0 ( ) {
164+ let mut i2c = MockI2CDevice :: new ( ) ;
165+ let value = i2c. smbus_read_byte_data ( 0 ) . unwrap ( ) ;
166+ assert_eq ! ( value, 0 ) ;
167+ }
You can’t perform that action at this time.
0 commit comments