Skip to main content

run_target_handshake_with_initial_data

Function run_target_handshake_with_initial_data 

Source
pub async fn run_target_handshake_with_initial_data<S: SerialRead + SerialWrite>(
    device: &mut S,
    initial_data: &[u8],
) -> Result<(ProtocolId, u32, Vec<u8>)>
Expand description

Runs the target-side framing protocol handshake seeded with initial_data.

Feeds initial_data into the frame parser before reading additional bytes from device, allowing carry-over bytes from a previous session to be processed without loss. Invalid or unsupported NegotiateReq payloads are rejected in-band while continuing to wait for a valid handshake on device.

ยงErrors

Returns TargetDriverError::EmptyRead if the serial device returns EOF before negotiation completes, or an I/O/framing error if reading or writing to the serial device fails.