[−][src]Function rmodbus::guess_response_frame_len
pub fn guess_response_frame_len(
buf: &[u8],
proto: ModbusProto
) -> Result<u8, ErrorKind>
Guess response 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 will panic if the buffer length is less than 6 (3 for RTU, 7 for ASCII)
-
the function may return wrong result for broken frames
-
the function may return ErrorKind::FrameBroken for broken ASCII frames