Read all available bytes

This commit is contained in:
clerie 2024-12-23 17:14:11 +01:00
parent bc5b0959b2
commit b3b7a4ea27

View File

@ -65,8 +65,9 @@ impl SerialInterface {
} }
pub fn recv_bytes(&mut self) -> Result<Vec<u8>> { pub fn recv_bytes(&mut self) -> Result<Vec<u8>> {
let mut buffer: Vec<u8> = Vec::new(); let available_bytes = self.interface.bytes_to_read()?.try_into()?;
self.interface.read_to_end(&mut buffer); let mut buffer: Vec<u8> = vec![0; available_bytes];
self.interface.read(&mut buffer)?;
let improv_packet_offset = find_begin_of_improv_packet(&buffer).unwrap(); let improv_packet_offset = find_begin_of_improv_packet(&buffer).unwrap();