File tree 2 files changed +9
-0
lines changed
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).
9
9
## [ Unreleased]
10
10
11
11
- Derived common traits for public types.
12
+ - Fixed incrementing offset after a read with a ` MockI2CDevice ` .
12
13
13
14
## [ v0.6.0] - 2023-08-03
14
15
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ impl I2CRegisterMap {
45
45
fn read ( & mut self , data : & mut [ u8 ] ) -> I2CResult < ( ) > {
46
46
let len = data. len ( ) ;
47
47
data. clone_from_slice ( & self . registers [ self . offset ..( self . offset + len) ] ) ;
48
+ self . offset += data. len ( ) ;
48
49
println ! ( "READ | 0x{:X} : {:?}" , self . offset - data. len( ) , data) ;
49
50
Ok ( ( ) )
50
51
}
@@ -157,3 +158,10 @@ where
157
158
Ok ( messages. len ( ) as u32 )
158
159
}
159
160
}
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