From 894c76a342f83e3314f419dbcc7655d52af3ca24 Mon Sep 17 00:00:00 2001 From: Jack Date: Thu, 2 Jun 2022 12:26:07 -0700 Subject: [PATCH 1/2] Use File.read_exact instead of File.read --- src/linux.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/linux.rs b/src/linux.rs index 67d09ff3..f75439bb 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -175,7 +175,7 @@ impl I2CDevice for LinuxI2CDevice { /// Read data from the device to fill the provided slice fn read(&mut self, data: &mut [u8]) -> Result<(), LinuxI2CError> { - self.devfile.read(data).map_err(From::from).map(drop) + self.devfile.read_exact(data).map_err(From::from).map(drop) } /// Write the provided buffer to the device From f6858e421f8198e46611690dd90faa414060eda5 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 6 Jun 2022 13:53:32 -0700 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d1fb626..58288eac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] - Updated nix to version `0.24`; only use the `ioctl` feature. +- Use `File.read_exact` instead of `File.read` in `LinuxI2CDevice.read` so that the buffer is filled. ## [v0.5.1] - 2021-11-22