Skip to content

Commit 594860e

Browse files
authored
Merge pull request #81 from eldruin/prepare-0.6.0
Prepare 0.6.0 release
2 parents 9516c1f + 62052ee commit 594860e

File tree

11 files changed

+63
-82
lines changed

11 files changed

+63
-82
lines changed

.github/workflows/ci.yml

+8-24
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,21 @@ jobs:
3131
TARGET: x86_64-unknown-linux-gnu
3232

3333
steps:
34-
- uses: actions/checkout@v2
35-
36-
- uses: actions-rs/toolchain@v1
34+
- uses: actions/checkout@v3
35+
- uses: dtolnay/rust-toolchain@master
3736
with:
38-
profile: minimal
3937
toolchain: ${{ matrix.rust }}
4038
target: ${{ matrix.TARGET }}
41-
override: true
4239

4340
- name: Install armv7 libraries
4441
if: ${{ matrix.TARGET == 'armv7-unknown-linux-gnueabihf' }}
45-
run: sudo apt-get install -y libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf
42+
run: sudo apt-get update && sudo apt-get install -y libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf
4643

47-
- uses: actions-rs/cargo@v1
44+
- run: cargo test --target=${{ matrix.TARGET }}
4845
if: ${{ matrix.TARGET != 'armv7-unknown-linux-gnueabihf' }}
49-
with:
50-
command: test
51-
args: --target=${{ matrix.TARGET }}
52-
5346

54-
- uses: actions-rs/cargo@v1
47+
- run: cargo build --target=${{ matrix.TARGET }}
5548
if: ${{ matrix.TARGET == 'armv7-unknown-linux-gnueabihf' }}
56-
with:
57-
command: build
58-
args: --target=${{ matrix.TARGET }}
5949

6050
ci-macos:
6151
name: CI-macOS
@@ -67,16 +57,10 @@ jobs:
6757
TARGET: [x86_64-apple-darwin]
6858

6959
steps:
70-
- uses: actions/checkout@v2
71-
72-
- uses: actions-rs/toolchain@v1
60+
- uses: actions/checkout@v3
61+
- uses: dtolnay/rust-toolchain@master
7362
with:
74-
profile: minimal
7563
toolchain: ${{ matrix.rust }}
7664
target: ${{ matrix.TARGET }}
77-
override: true
7865

79-
- uses: actions-rs/cargo@v1
80-
with:
81-
command: build
82-
args: --target=${{ matrix.TARGET }}
66+
- run: cargo build --target=${{ matrix.TARGET }}

.github/workflows/clippy.yml

+4-8
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@ jobs:
1010
clippy_check:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions-rs/toolchain@v1
13+
- uses: actions/checkout@v3
14+
- uses: dtolnay/rust-toolchain@master
1515
with:
16-
profile: minimal
17-
toolchain: 1.55.0
18-
override: true
16+
toolchain: 1.71.0
1917
components: clippy
20-
- uses: actions-rs/clippy-check@v1
21-
with:
22-
token: ${{ secrets.GITHUB_TOKEN }}
18+
- run: cargo clippy

.github/workflows/rustfmt.yml

+4-9
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,9 @@ jobs:
1212
name: Rustfmt
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v2
16-
- uses: actions-rs/toolchain@v1
15+
- uses: actions/checkout@v3
16+
- uses: dtolnay/rust-toolchain@master
1717
with:
18-
profile: minimal
19-
toolchain: stable
20-
override: true
18+
toolchain: 1.71.0
2119
components: rustfmt
22-
- uses: actions-rs/cargo@v1
23-
with:
24-
command: fmt
25-
args: --all -- --check
20+
- run: cargo fmt --all -- --check

CHANGELOG.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ Versioning](https://semver.org/spec/v2.0.0.html).
88

99
## [Unreleased]
1010

11+
## [v0.6.0] - 2023-08-03
12+
1113
- Hide nix from the public api such that it can be updated without resulting in a breaking change.
12-
- Updated nix to version `0.25`.
13-
- Updated nix to version `0.24`; only use the `ioctl` feature.
14+
- Updated nix to version `0.26`; only use the `ioctl` feature.
15+
- Updated `bitflags` to version `2.3`.
1416
- Use `File.read_exact` instead of `File.read` in `LinuxI2CDevice.read` so that the buffer is filled.
1517
- Fix the lifetime parameter on `LinuxI2CMessage` to ensure that it does not outlive the buffer it points to.
1618
- Updated MSRV to 1.60.0.
@@ -31,6 +33,7 @@ Versioning](https://semver.org/spec/v2.0.0.html).
3133

3234
The changelog for previous versions was not recorded.
3335

34-
[Unreleased]: https://github.com/rust-embedded/rust-i2cdev/compare/0.5.1...HEAD
36+
[Unreleased]: https://github.com/rust-embedded/rust-i2cdev/compare/0.6.0...HEAD
37+
[v0.6.0]: https://github.com/rust-embedded/rust-i2cdev/compare/0.5.1...0.6.0
3538
[v0.5.1]: https://github.com/rust-embedded/rust-i2cdev/compare/0.5.0...0.5.1
3639
[v0.5.0]: https://github.com/rust-embedded/rust-i2cdev/compare/0.4.0...0.5.0

Cargo.toml

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
[package]
22

33
name = "i2cdev"
4-
version = "0.5.1"
5-
authors = ["Paul Osborne <[email protected]>"]
4+
version = "0.6.0"
5+
authors = [
6+
"Paul Osborne <[email protected]>",
7+
"The Embedded Linux Team <[email protected]>"
8+
]
69
license = "MIT/Apache-2.0"
710
repository = "https://github.com/rust-embedded/rust-i2cdev"
811
homepage = "https://github.com/rust-embedded/rust-i2cdev"
@@ -16,9 +19,9 @@ Provides API for safe access to Linux i2c device interface.
1619

1720
[dependencies]
1821
libc = "0.2"
19-
bitflags = "1.3"
22+
bitflags = "2.3"
2023
byteorder = "1"
21-
nix = { version = "0.25", default-features = false, features = ["ioctl"] }
24+
nix = { version = "0.26.2", default-features = false, features = ["ioctl"] }
2225

2326
[dev-dependencies]
2427
docopt = "1"

LICENSE-MIT

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
The MIT License (MIT)
22

33
Copyright (c) 2015 Paul Osborne
4+
Copyright (c) 2021-2023 The Rust Embedded Linux Team and contributors.
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
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
1920
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2021
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2122
SOFTWARE.
22-

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![Build Status](https://github.com/rust-embedded/rust-i2cdev/workflows/CI/badge.svg)](https://github.com/rust-embedded/rust-i2cdev/actions)
44
[![Version](https://img.shields.io/crates/v/i2cdev.svg)](https://crates.io/crates/i2cdev)
55
[![License](https://img.shields.io/crates/l/i2cdev.svg)](https://github.com/rust-embedded/rust-i2cdev/blob/master/README.md#license)
6+
![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.60+-blue.svg)
67

78
[Documentation](https://docs.rs/i2cdev)
89

@@ -49,7 +50,7 @@ The following features are implemented and planned for the library:
4950

5051
Most likely, the machine you are running on is not your development
5152
machine (although it could be). In those cases, you will need to
52-
cross-compile. See https://github.com/japaric/rust-cross for pointers.
53+
cross-compile. See <https://github.com/cross-rs/cross> for pointers.
5354

5455
## Minimum Supported Rust Version (MSRV)
5556

examples/nunchuck.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ mod nunchuck {
5858

5959
#[derive(Debug)]
6060
pub struct NunchuckReading {
61-
joystick_x: u8,
62-
joystick_y: u8,
63-
accel_x: u16, // 10-bit
64-
accel_y: u16, // 10-bit
65-
accel_z: u16, // 10-bit
66-
c_button_pressed: bool,
67-
z_button_pressed: bool,
61+
pub joystick_x: u8,
62+
pub joystick_y: u8,
63+
pub accel_x: u16, // 10-bit
64+
pub accel_y: u16, // 10-bit
65+
pub accel_z: u16, // 10-bit
66+
pub c_button_pressed: bool,
67+
pub z_button_pressed: bool,
6868
}
6969

7070
impl NunchuckReading {

examples/sensors.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,8 @@ mod sensors {
285285
// If values are less than 16 bytes, need to adjust
286286
let extrabits = 16 - integer_bits - fractional_bits - 1;
287287
let rawval: i16 = BigEndian::read_i16(&[msb, lsb]);
288-
let adj = (f32::from(rawval) / 2_f32.powi(fractional_bits + extrabits))
289-
/ 10_f32.powi(dec_pt_zero_pad);
290-
adj
288+
(f32::from(rawval) / 2_f32.powi(fractional_bits + extrabits))
289+
/ 10_f32.powi(dec_pt_zero_pad)
291290
}
292291

293292
impl MPL115A2Coefficients {

src/ffi.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,24 @@ bitflags! {
5555
const I2C_FUNC_SMBUS_READ_I2C_BLOCK = 0x0400_0000; /* I2C-like block xfer */
5656
const I2C_FUNC_SMBUS_WRITE_I2C_BLOCK = 0x0800_0000; /* w/ 1-byte reg. addr. */
5757

58-
const I2C_FUNC_SMBUS_BYTE = (I2CFunctions::I2C_FUNC_SMBUS_READ_BYTE.bits |
59-
I2CFunctions::I2C_FUNC_SMBUS_WRITE_BYTE.bits);
60-
const I2C_FUNC_SMBUS_BYTE_DATA = (I2CFunctions::I2C_FUNC_SMBUS_READ_BYTE_DATA.bits |
61-
I2CFunctions::I2C_FUNC_SMBUS_WRITE_BYTE_DATA.bits);
62-
const I2C_FUNC_SMBUS_WORD_DATA = (I2CFunctions::I2C_FUNC_SMBUS_READ_WORD_DATA.bits |
63-
I2CFunctions::I2C_FUNC_SMBUS_WRITE_WORD_DATA.bits);
64-
const I2C_FUNC_SMBUS_BLOCK_DATA = (I2CFunctions::I2C_FUNC_SMBUS_READ_BLOCK_DATA.bits |
65-
I2CFunctions::I2C_FUNC_SMBUS_WRITE_BLOCK_DATA.bits);
66-
const I2C_FUNC_SMBUS_I2C_BLOCK = (I2CFunctions::I2C_FUNC_SMBUS_READ_I2C_BLOCK.bits |
67-
I2CFunctions::I2C_FUNC_SMBUS_WRITE_I2C_BLOCK.bits);
68-
const I2C_FUNC_SMBUS_EMUL = (I2CFunctions::I2C_FUNC_SMBUS_QUICK.bits |
69-
I2CFunctions::I2C_FUNC_SMBUS_BYTE.bits |
70-
I2CFunctions::I2C_FUNC_SMBUS_BYTE_DATA.bits |
71-
I2CFunctions::I2C_FUNC_SMBUS_WORD_DATA.bits |
72-
I2CFunctions::I2C_FUNC_SMBUS_PROC_CALL.bits |
73-
I2CFunctions::I2C_FUNC_SMBUS_WRITE_BLOCK_DATA.bits |
74-
I2CFunctions::I2C_FUNC_SMBUS_I2C_BLOCK.bits |
75-
I2CFunctions::I2C_FUNC_SMBUS_PEC.bits);
58+
const I2C_FUNC_SMBUS_BYTE = (I2CFunctions::I2C_FUNC_SMBUS_READ_BYTE.bits() |
59+
I2CFunctions::I2C_FUNC_SMBUS_WRITE_BYTE.bits());
60+
const I2C_FUNC_SMBUS_BYTE_DATA = (I2CFunctions::I2C_FUNC_SMBUS_READ_BYTE_DATA.bits() |
61+
I2CFunctions::I2C_FUNC_SMBUS_WRITE_BYTE_DATA.bits());
62+
const I2C_FUNC_SMBUS_WORD_DATA = (I2CFunctions::I2C_FUNC_SMBUS_READ_WORD_DATA.bits() |
63+
I2CFunctions::I2C_FUNC_SMBUS_WRITE_WORD_DATA.bits());
64+
const I2C_FUNC_SMBUS_BLOCK_DATA = (I2CFunctions::I2C_FUNC_SMBUS_READ_BLOCK_DATA.bits() |
65+
I2CFunctions::I2C_FUNC_SMBUS_WRITE_BLOCK_DATA.bits());
66+
const I2C_FUNC_SMBUS_I2C_BLOCK = (I2CFunctions::I2C_FUNC_SMBUS_READ_I2C_BLOCK.bits() |
67+
I2CFunctions::I2C_FUNC_SMBUS_WRITE_I2C_BLOCK.bits());
68+
const I2C_FUNC_SMBUS_EMUL = (I2CFunctions::I2C_FUNC_SMBUS_QUICK.bits() |
69+
I2CFunctions::I2C_FUNC_SMBUS_BYTE.bits() |
70+
I2CFunctions::I2C_FUNC_SMBUS_BYTE_DATA.bits() |
71+
I2CFunctions::I2C_FUNC_SMBUS_WORD_DATA.bits() |
72+
I2CFunctions::I2C_FUNC_SMBUS_PROC_CALL.bits() |
73+
I2CFunctions::I2C_FUNC_SMBUS_WRITE_BLOCK_DATA.bits() |
74+
I2CFunctions::I2C_FUNC_SMBUS_I2C_BLOCK.bits() |
75+
I2CFunctions::I2C_FUNC_SMBUS_PEC.bits());
7676
}
7777
}
7878

@@ -354,7 +354,7 @@ pub fn i2c_smbus_read_block_data(fd: RawFd, register: u8) -> Result<Vec<u8>, I2C
354354
// create a vector from the data in the block starting at byte
355355
// 1 and ending after count bytes after that
356356
let count = data.block[0];
357-
Ok((&data.block[1..(count + 1) as usize]).to_vec())
357+
Ok((data.block[1..(count + 1) as usize]).to_vec())
358358
}
359359

360360
pub fn i2c_smbus_read_i2c_block_data(
@@ -377,7 +377,7 @@ pub fn i2c_smbus_read_i2c_block_data(
377377
// create a vector from the data in the block starting at byte
378378
// 1 and ending after count bytes after that
379379
let count = data.block[0];
380-
Ok((&data.block[1..(count + 1) as usize]).to_vec())
380+
Ok((data.block[1..(count + 1) as usize]).to_vec())
381381
}
382382

383383
#[inline]
@@ -445,7 +445,7 @@ pub fn i2c_smbus_process_call_block(
445445
// create a vector from the data in the block starting at byte
446446
// 1 and ending after count bytes after that
447447
let count = data.block[0];
448-
Ok((&data.block[1..(count + 1) as usize]).to_vec())
448+
Ok((data.block[1..(count + 1) as usize]).to_vec())
449449
}
450450

451451
#[inline]

src/linux.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ impl<'a> I2CTransfer<'a> for LinuxI2CDevice {
301301
/// Issue the provided sequence of I2C transactions
302302
fn transfer(&mut self, messages: &'a mut [Self::Message]) -> Result<u32, LinuxI2CError> {
303303
for msg in messages.iter_mut() {
304-
(*msg).addr = self.slave_address;
304+
msg.addr = self.slave_address;
305305
}
306306
ffi::i2c_rdwr(self.as_raw_fd(), messages).map_err(From::from)
307307
}

0 commit comments

Comments
 (0)