diff --git a/src/lib.rs b/src/lib.rs index 4ef314a031cc163ef7c193d75002815b9e84d20d..cae93d4d6ba6b4063ab9ddfde6cd78294ac11351 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -153,7 +153,7 @@ fn read_from_serial(mut outputs: Output<'_>, args: Args<'_>) -> SResult<()> { let bytes = SERIAL.read().read_n_bytes(&port, n_bytes)?; let doubles = bytes .chunks_exact(4) - .map(|chunk| f32::from_be_bytes(chunk.try_into().unwrap())) + .map(|chunk| f32::from_le_bytes(chunk.try_into().unwrap())) .collect::<Vec<f32>>(); warn_debug!( "Read {} ({} singles) bytes from serial port", @@ -176,7 +176,7 @@ fn write_to_serial(args: Args<'_>) -> SResult<()> { .map_mexerr(|e| Error::InvalidWriteData(Box::new(e)))?; // Convert the doubles to a stream of bytes and write them to the serial port - let data: Vec<u8> = data.iter().flat_map(|&x| x.to_be_bytes()).collect(); + let data: Vec<u8> = data.iter().flat_map(|&x| x.to_le_bytes()).collect(); SERIAL.read().enqueue_bytes(&port, &data)?; warn_debug!("Wrote {} bytes to serial port", data.len()); Ok(())