Function libmodbus_rs::prelude::set_float_cdab [] [src]

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

set_float_cdab - set a float value in 2 registers using CDAB byte order

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

Parameters

Examples

use libmodbus_rs::prelude::*;

let mut dest = vec![0; 2];
set_float_cdab(123456.0, &mut dest);
assert_eq!(&dest, &[0xF147, 0x0020]);