pub struct ReadCoils {
pub addr: u16,
pub quantity: u16,
}
Expand description
The request structure to read Coils
used to parse and build modbus data to read quantity entities starting from addr.
Fields§
§addr: u16
§quantity: u16
Implementations§
Source§impl ReadCoils
impl ReadCoils
Sourcepub const MODBUS_FUNCTION_CODE: PublicModbusFunction = PublicModbusFunction::ReadCoils
pub const MODBUS_FUNCTION_CODE: PublicModbusFunction = PublicModbusFunction::ReadCoils
The Modbus function this read requests corresponds to.
Sourcepub fn from_data(data: &[u8]) -> Result<(Self, &[u8]), ModbusSerializationError>
pub fn from_data(data: &[u8]) -> Result<(Self, &[u8]), ModbusSerializationError>
Parse this request from the given modbus data
The data should only consist out of the address and quantity as the slave id function will be already read through other means.
Sourcepub unsafe fn from_data_unchecked(data: &[u8]) -> (Self, &[u8])
pub unsafe fn from_data_unchecked(data: &[u8]) -> (Self, &[u8])
Parse this request from the given modbus data without bounds checks.
The data should only consist out of the address and quantity as the slave id function will be already read through other means.
§Safety
This function causes undefined behavior if the len of data is smaller than 4
Sourcepub fn into_data(self) -> [u8; 5]
pub fn into_data(self) -> [u8; 5]
Create modbus data of the correct size from this request
The format of the array will be [addrhi, addrlo, quantityhi, quantitylo] in big endian
Sourcepub fn write_to_slice(
self,
out: &mut [u8],
) -> Result<(), ModbusSerializationError>
pub fn write_to_slice( self, out: &mut [u8], ) -> Result<(), ModbusSerializationError>
Write this request to the slice as modbus data
Sourcepub unsafe fn write_to_slice_unchecked(self, out: &mut [u8])
pub unsafe fn write_to_slice_unchecked(self, out: &mut [u8])
Write this request to the slice as modbus data without bounds checking.
§Safety
This function invokes undefined behavior if the len of data is less than 5