From 6ab8417db5cf00d38d9a1943bab43dfa8643cbb3 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Tue, 1 Aug 2023 18:36:39 +0200 Subject: [PATCH 1/7] Update readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7bc280d7..642e92fa 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Build Status](https://github.com/rust-embedded/rust-i2cdev/workflows/CI/badge.svg)](https://github.com/rust-embedded/rust-i2cdev/actions) [![Version](https://img.shields.io/crates/v/i2cdev.svg)](https://crates.io/crates/i2cdev) [![License](https://img.shields.io/crates/l/i2cdev.svg)](https://github.com/rust-embedded/rust-i2cdev/blob/master/README.md#license) +![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.60+-blue.svg) [Documentation](https://docs.rs/i2cdev) @@ -49,7 +50,7 @@ The following features are implemented and planned for the library: Most likely, the machine you are running on is not your development machine (although it could be). In those cases, you will need to -cross-compile. See https://github.com/japaric/rust-cross for pointers. +cross-compile. See for pointers. ## Minimum Supported Rust Version (MSRV) From be1bf6d6654d3cc05e38afb7f9bf17bcbd340561 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Tue, 1 Aug 2023 18:36:53 +0200 Subject: [PATCH 2/7] Update nix and bitflags --- CHANGELOG.md | 4 ++-- Cargo.toml | 4 ++-- src/ffi.rs | 36 ++++++++++++++++++------------------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac10d5a3..4a807999 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] - Hide nix from the public api such that it can be updated without resulting in a breaking change. -- Updated nix to version `0.25`. -- Updated nix to version `0.24`; only use the `ioctl` feature. +- Updated nix to version `0.26`; only use the `ioctl` feature. +- Updated `bitflags` to version `2.3`. - Use `File.read_exact` instead of `File.read` in `LinuxI2CDevice.read` so that the buffer is filled. - Fix the lifetime parameter on `LinuxI2CMessage` to ensure that it does not outlive the buffer it points to. - Updated MSRV to 1.60.0. diff --git a/Cargo.toml b/Cargo.toml index 8e681f3c..d7f687b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,9 +16,9 @@ Provides API for safe access to Linux i2c device interface. [dependencies] libc = "0.2" -bitflags = "1.3" +bitflags = "2.3" byteorder = "1" -nix = { version = "0.25", default-features = false, features = ["ioctl"] } +nix = { version = "0.26", default-features = false, features = ["ioctl"] } [dev-dependencies] docopt = "1" diff --git a/src/ffi.rs b/src/ffi.rs index fbe733d4..3fadd70b 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -55,24 +55,24 @@ bitflags! { const I2C_FUNC_SMBUS_READ_I2C_BLOCK = 0x0400_0000; /* I2C-like block xfer */ const I2C_FUNC_SMBUS_WRITE_I2C_BLOCK = 0x0800_0000; /* w/ 1-byte reg. addr. */ - const I2C_FUNC_SMBUS_BYTE = (I2CFunctions::I2C_FUNC_SMBUS_READ_BYTE.bits | - I2CFunctions::I2C_FUNC_SMBUS_WRITE_BYTE.bits); - const I2C_FUNC_SMBUS_BYTE_DATA = (I2CFunctions::I2C_FUNC_SMBUS_READ_BYTE_DATA.bits | - I2CFunctions::I2C_FUNC_SMBUS_WRITE_BYTE_DATA.bits); - const I2C_FUNC_SMBUS_WORD_DATA = (I2CFunctions::I2C_FUNC_SMBUS_READ_WORD_DATA.bits | - I2CFunctions::I2C_FUNC_SMBUS_WRITE_WORD_DATA.bits); - const I2C_FUNC_SMBUS_BLOCK_DATA = (I2CFunctions::I2C_FUNC_SMBUS_READ_BLOCK_DATA.bits | - I2CFunctions::I2C_FUNC_SMBUS_WRITE_BLOCK_DATA.bits); - const I2C_FUNC_SMBUS_I2C_BLOCK = (I2CFunctions::I2C_FUNC_SMBUS_READ_I2C_BLOCK.bits | - I2CFunctions::I2C_FUNC_SMBUS_WRITE_I2C_BLOCK.bits); - const I2C_FUNC_SMBUS_EMUL = (I2CFunctions::I2C_FUNC_SMBUS_QUICK.bits | - I2CFunctions::I2C_FUNC_SMBUS_BYTE.bits | - I2CFunctions::I2C_FUNC_SMBUS_BYTE_DATA.bits | - I2CFunctions::I2C_FUNC_SMBUS_WORD_DATA.bits | - I2CFunctions::I2C_FUNC_SMBUS_PROC_CALL.bits | - I2CFunctions::I2C_FUNC_SMBUS_WRITE_BLOCK_DATA.bits | - I2CFunctions::I2C_FUNC_SMBUS_I2C_BLOCK.bits | - I2CFunctions::I2C_FUNC_SMBUS_PEC.bits); + const I2C_FUNC_SMBUS_BYTE = (I2CFunctions::I2C_FUNC_SMBUS_READ_BYTE.bits() | + I2CFunctions::I2C_FUNC_SMBUS_WRITE_BYTE.bits()); + const I2C_FUNC_SMBUS_BYTE_DATA = (I2CFunctions::I2C_FUNC_SMBUS_READ_BYTE_DATA.bits() | + I2CFunctions::I2C_FUNC_SMBUS_WRITE_BYTE_DATA.bits()); + const I2C_FUNC_SMBUS_WORD_DATA = (I2CFunctions::I2C_FUNC_SMBUS_READ_WORD_DATA.bits() | + I2CFunctions::I2C_FUNC_SMBUS_WRITE_WORD_DATA.bits()); + const I2C_FUNC_SMBUS_BLOCK_DATA = (I2CFunctions::I2C_FUNC_SMBUS_READ_BLOCK_DATA.bits() | + I2CFunctions::I2C_FUNC_SMBUS_WRITE_BLOCK_DATA.bits()); + const I2C_FUNC_SMBUS_I2C_BLOCK = (I2CFunctions::I2C_FUNC_SMBUS_READ_I2C_BLOCK.bits() | + I2CFunctions::I2C_FUNC_SMBUS_WRITE_I2C_BLOCK.bits()); + const I2C_FUNC_SMBUS_EMUL = (I2CFunctions::I2C_FUNC_SMBUS_QUICK.bits() | + I2CFunctions::I2C_FUNC_SMBUS_BYTE.bits() | + I2CFunctions::I2C_FUNC_SMBUS_BYTE_DATA.bits() | + I2CFunctions::I2C_FUNC_SMBUS_WORD_DATA.bits() | + I2CFunctions::I2C_FUNC_SMBUS_PROC_CALL.bits() | + I2CFunctions::I2C_FUNC_SMBUS_WRITE_BLOCK_DATA.bits() | + I2CFunctions::I2C_FUNC_SMBUS_I2C_BLOCK.bits() | + I2CFunctions::I2C_FUNC_SMBUS_PEC.bits()); } } From 52493da9d7ed489feb0ccd4cfd9b958467afce78 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Tue, 1 Aug 2023 18:37:46 +0200 Subject: [PATCH 3/7] Add rust-embedded linux team as author --- Cargo.toml | 5 ++++- LICENSE-MIT | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d7f687b7..3971ff9c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,10 @@ name = "i2cdev" version = "0.5.1" -authors = ["Paul Osborne "] +authors = [ + "Paul Osborne ", + "The Embedded Linux Team " +] license = "MIT/Apache-2.0" repository = "https://github.com/rust-embedded/rust-i2cdev" homepage = "https://github.com/rust-embedded/rust-i2cdev" diff --git a/LICENSE-MIT b/LICENSE-MIT index c70652f0..e320efc2 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,6 +1,7 @@ The MIT License (MIT) Copyright (c) 2015 Paul Osborne +Copyright (c) 2021-2023 The Rust Embedded Linux Team and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,4 +20,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - From ea3ee5b89c1c58c229ff1c43c660d707d9d97207 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Tue, 1 Aug 2023 18:38:54 +0200 Subject: [PATCH 4/7] Update minimum nix version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3971ff9c..5977e9c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ Provides API for safe access to Linux i2c device interface. libc = "0.2" bitflags = "2.3" byteorder = "1" -nix = { version = "0.26", default-features = false, features = ["ioctl"] } +nix = { version = "0.26.2", default-features = false, features = ["ioctl"] } [dev-dependencies] docopt = "1" From b283b82b9b9ca1fe3f7c1086635c4ca880063b90 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Tue, 1 Aug 2023 18:49:49 +0200 Subject: [PATCH 5/7] Fix warnings --- examples/nunchuck.rs | 14 +++++++------- examples/sensors.rs | 5 ++--- src/ffi.rs | 6 +++--- src/linux.rs | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/examples/nunchuck.rs b/examples/nunchuck.rs index 50f5e980..9af0242c 100644 --- a/examples/nunchuck.rs +++ b/examples/nunchuck.rs @@ -58,13 +58,13 @@ mod nunchuck { #[derive(Debug)] pub struct NunchuckReading { - joystick_x: u8, - joystick_y: u8, - accel_x: u16, // 10-bit - accel_y: u16, // 10-bit - accel_z: u16, // 10-bit - c_button_pressed: bool, - z_button_pressed: bool, + pub joystick_x: u8, + pub joystick_y: u8, + pub accel_x: u16, // 10-bit + pub accel_y: u16, // 10-bit + pub accel_z: u16, // 10-bit + pub c_button_pressed: bool, + pub z_button_pressed: bool, } impl NunchuckReading { diff --git a/examples/sensors.rs b/examples/sensors.rs index a9f3f7ba..4fc9c0cb 100644 --- a/examples/sensors.rs +++ b/examples/sensors.rs @@ -285,9 +285,8 @@ mod sensors { // If values are less than 16 bytes, need to adjust let extrabits = 16 - integer_bits - fractional_bits - 1; let rawval: i16 = BigEndian::read_i16(&[msb, lsb]); - let adj = (f32::from(rawval) / 2_f32.powi(fractional_bits + extrabits)) - / 10_f32.powi(dec_pt_zero_pad); - adj + (f32::from(rawval) / 2_f32.powi(fractional_bits + extrabits)) + / 10_f32.powi(dec_pt_zero_pad) } impl MPL115A2Coefficients { diff --git a/src/ffi.rs b/src/ffi.rs index 3fadd70b..aaab92c2 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -354,7 +354,7 @@ pub fn i2c_smbus_read_block_data(fd: RawFd, register: u8) -> Result, I2C // create a vector from the data in the block starting at byte // 1 and ending after count bytes after that let count = data.block[0]; - Ok((&data.block[1..(count + 1) as usize]).to_vec()) + Ok((data.block[1..(count + 1) as usize]).to_vec()) } pub fn i2c_smbus_read_i2c_block_data( @@ -377,7 +377,7 @@ pub fn i2c_smbus_read_i2c_block_data( // create a vector from the data in the block starting at byte // 1 and ending after count bytes after that let count = data.block[0]; - Ok((&data.block[1..(count + 1) as usize]).to_vec()) + Ok((data.block[1..(count + 1) as usize]).to_vec()) } #[inline] @@ -445,7 +445,7 @@ pub fn i2c_smbus_process_call_block( // create a vector from the data in the block starting at byte // 1 and ending after count bytes after that let count = data.block[0]; - Ok((&data.block[1..(count + 1) as usize]).to_vec()) + Ok((data.block[1..(count + 1) as usize]).to_vec()) } #[inline] diff --git a/src/linux.rs b/src/linux.rs index 18cbb180..4e855037 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -301,7 +301,7 @@ impl<'a> I2CTransfer<'a> for LinuxI2CDevice { /// Issue the provided sequence of I2C transactions fn transfer(&mut self, messages: &'a mut [Self::Message]) -> Result { for msg in messages.iter_mut() { - (*msg).addr = self.slave_address; + msg.addr = self.slave_address; } ffi::i2c_rdwr(self.as_raw_fd(), messages).map_err(From::from) } From 14bab5aba1201ae3ddf971a3045cc9104b4cc6b5 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Tue, 1 Aug 2023 19:14:46 +0200 Subject: [PATCH 6/7] Update CI --- .github/workflows/ci.yml | 32 ++++++++------------------------ .github/workflows/clippy.yml | 12 ++++-------- .github/workflows/rustfmt.yml | 13 ++++--------- 3 files changed, 16 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44635006..8af25e98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,31 +31,21 @@ jobs: TARGET: x86_64-unknown-linux-gnu steps: - - uses: actions/checkout@v2 - - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: ${{ matrix.rust }} target: ${{ matrix.TARGET }} - override: true - name: Install armv7 libraries if: ${{ matrix.TARGET == 'armv7-unknown-linux-gnueabihf' }} - run: sudo apt-get install -y libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf + run: sudo apt-get update && sudo apt-get install -y libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf - - uses: actions-rs/cargo@v1 + - run: cargo test --target=${{ matrix.TARGET }} if: ${{ matrix.TARGET != 'armv7-unknown-linux-gnueabihf' }} - with: - command: test - args: --target=${{ matrix.TARGET }} - - - uses: actions-rs/cargo@v1 + - run: cargo build --target=${{ matrix.TARGET }} if: ${{ matrix.TARGET == 'armv7-unknown-linux-gnueabihf' }} - with: - command: build - args: --target=${{ matrix.TARGET }} ci-macos: name: CI-macOS @@ -67,16 +57,10 @@ jobs: TARGET: [x86_64-apple-darwin] steps: - - uses: actions/checkout@v2 - - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: ${{ matrix.rust }} target: ${{ matrix.TARGET }} - override: true - - uses: actions-rs/cargo@v1 - with: - command: build - args: --target=${{ matrix.TARGET }} + - run: cargo build --target=${{ matrix.TARGET }} diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index f2c654ac..e6bc5bf9 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -10,13 +10,9 @@ jobs: clippy_check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal - toolchain: 1.55.0 - override: true + toolchain: 1.71.0 components: clippy - - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} + - run: cargo clippy diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml index de591564..9c597032 100644 --- a/.github/workflows/rustfmt.yml +++ b/.github/workflows/rustfmt.yml @@ -12,14 +12,9 @@ jobs: name: Rustfmt runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal - toolchain: stable - override: true + toolchain: 1.71.0 components: rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check + - run: cargo fmt --all -- --check From 62052ee509ce350959a48c1ec182abb85894d4f1 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Thu, 3 Aug 2023 07:15:05 +0200 Subject: [PATCH 7/7] Prepare 0.6.0 release --- CHANGELOG.md | 5 ++++- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a807999..925fc4f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [v0.6.0] - 2023-08-03 + - Hide nix from the public api such that it can be updated without resulting in a breaking change. - Updated nix to version `0.26`; only use the `ioctl` feature. - Updated `bitflags` to version `2.3`. @@ -31,6 +33,7 @@ Versioning](https://semver.org/spec/v2.0.0.html). The changelog for previous versions was not recorded. -[Unreleased]: https://github.com/rust-embedded/rust-i2cdev/compare/0.5.1...HEAD +[Unreleased]: https://github.com/rust-embedded/rust-i2cdev/compare/0.6.0...HEAD +[v0.6.0]: https://github.com/rust-embedded/rust-i2cdev/compare/0.5.1...0.6.0 [v0.5.1]: https://github.com/rust-embedded/rust-i2cdev/compare/0.5.0...0.5.1 [v0.5.0]: https://github.com/rust-embedded/rust-i2cdev/compare/0.4.0...0.5.0 diff --git a/Cargo.toml b/Cargo.toml index 5977e9c0..a3b1e3b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "i2cdev" -version = "0.5.1" +version = "0.6.0" authors = [ "Paul Osborne ", "The Embedded Linux Team "