Function libmodbus_rs::prelude::set_float_abcd [] [src]

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

set_float_abcd - set a float value in 2 registers using ABCD byte order

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

Parameters

  • src - float to 4 bytes (f32)
  • dest - slice must contain two u16 values

Examples

use libmodbus_rs::prelude::*;

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