In rust, I write:
let buf = binary::unpack_bytes(®isters);
The problem is, that even when specifying the "word order" here, it wouldn't work, because it needs to be applied on a per register basis. So currently, I read 8 and 16 bit values directly from the buffer, while I hacked this helper function for 32 bit values:
fn read_big_little_i32<R: Read>(mut inbuf: R) -> Result<i32> {
let a = inbuf.read_u8()?;
let b = inbuf.read_u8()?;
let c = inbuf.read_u8()?;
let d = inbuf.read_u8()?;
let buf = &[c, d, a, b];
(&buf[..]).read_i32::<byteorder::BE>()
}
Am I missing something here? Can this be done simpler? :-)
I am porting some code from python to rust. In python I write:
In rust, I write:
let buf = binary::unpack_bytes(®isters);
The problem is, that even when specifying the "word order" here, it wouldn't work, because it needs to be applied on a per register basis. So currently, I read 8 and 16 bit values directly from the buffer, while I hacked this helper function for 32 bit values:
Am I missing something here? Can this be done simpler? :-)