Function rmodbus::guess_request_frame_len
source · pub fn guess_request_frame_len(
frame: &[u8],
proto: ModbusProto
) -> Result<u8, ErrorKind>
Expand description
Guess request frame length
Frames are often read byte-by-byte. The function allows to guess total frame length, having first 7 (or more) bytes read.
How to use: read at least first 7 bytes (16 for ASCII) into buffer and call the function to guess the total frame length. The remaining amount of bytes to read will be function result - 7. 8 bytes is also fine, as that’s the minimal correct frame length.
-
the function may return wrong result for broken frames
-
the function may return ErrorKind::FrameBroken for broken ASCII frames
Panics
The function panics if the buffer length is less than 7 (for ASCII - 16)