Function libmodbus_rs::prelude::get_byte_from_bits [] [src]

pub fn get_byte_from_bits(src: &[u8], index: u8, num_bit: u16) -> u8

get_byte_from_bits - get the value from many bit

The get_byte_from_bits() function shall extract a value from many bits. All num_bit bits from src at position index will be read as a single value. To obtain a full byte, set num_bit to 8.

Return value

The function shall return a byte containing the bits read.

Parameters

Examples

use libmodbus_rs::{Modbus, ModbusMapping, ModbusTCP};
use libmodbus_rs::prelude::*;

let modbus = Modbus::new_tcp("127.0.0.1", 1502).unwrap();
let modbus_mapping = ModbusMapping::new(5, 5, 5, 5).unwrap();

assert_eq!(get_byte_from_bits(&[0b1111_1111], 0 ,8), 255);