Skip to content

Commit

Permalink
Merge pull request #81 from eldruin/prepare-0.6.0
Browse files Browse the repository at this point in the history
Prepare 0.6.0 release
  • Loading branch information
eldruin authored Aug 9, 2023
2 parents 9516c1f + 62052ee commit 594860e
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 82 deletions.
32 changes: 8 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
12 changes: 4 additions & 8 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 4 additions & 9 deletions .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ 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.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.
Expand All @@ -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
11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[package]

name = "i2cdev"
version = "0.5.1"
authors = ["Paul Osborne <[email protected]>"]
version = "0.6.0"
authors = [
"Paul Osborne <[email protected]>",
"The Embedded Linux Team <[email protected]>"
]
license = "MIT/Apache-2.0"
repository = "https://github.com/rust-embedded/rust-i2cdev"
homepage = "https://github.com/rust-embedded/rust-i2cdev"
Expand All @@ -16,9 +19,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.2", default-features = false, features = ["ioctl"] }

[dev-dependencies]
docopt = "1"
2 changes: 1 addition & 1 deletion LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 <https://github.com/cross-rs/cross> for pointers.

## Minimum Supported Rust Version (MSRV)

Expand Down
14 changes: 7 additions & 7 deletions examples/nunchuck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions examples/sensors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
42 changes: 21 additions & 21 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -354,7 +354,7 @@ pub fn i2c_smbus_read_block_data(fd: RawFd, register: u8) -> Result<Vec<u8>, 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(
Expand All @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32, LinuxI2CError> {
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)
}
Expand Down

0 comments on commit 594860e

Please sign in to comment.