Function libmodbus_rs::set_float_dcba [] [src]

pub fn set_float_dcba(src: f32, dest: &mut [u16])

set_float_dcba - set a float value in 2 registers using DCBA byte order

The set_float_dcba() function shall set a float to 4 bytes in swapped bytes Modbus format (DCBA insted of ABCD). The dest slice must contain two 16 bits values to be able to store the full result of the conversion.

Parameters

src - float to 4 bytes (f32) dest - slice must contain two 16 bits values

Examples

let mut dest = vec![0; 2];
libmodbus_rs::set_float_dcba(123456.0, &mut dest);
assert_eq!(&dest, &[0x47F1, 0x2000]);