Skip to main content

encode_bits_response

Function encode_bits_response 

Source
pub fn encode_bits_response(
    function_code: u8,
    values: &[bool],
) -> Result<Vec<u8>, EncodeError>
Expand description

PDU for a FC 1/2 read response: byte count then packed bits, least-significant bit of the first byte carrying the first requested coil.

Refuses a value list whose byte count would not fit rather than narrowing it with an as u8. At 2040 bits the narrowed count was 255 and at 2048 it was 0, both followed by the full data — a frame that lies about its own length.