Skip to content

Commit 666e769

Browse files
authored
Merge pull request #35 from rust-embedded/update-deps-and-prepare-release
Update dependencies to latest stable and fix fallout
2 parents bc12c4e + 4fa0d76 commit 666e769

File tree

5 files changed

+71
-82
lines changed

5 files changed

+71
-82
lines changed

.travis.yml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,6 @@ os:
55
- linux
66
- osx
77

8-
env:
9-
global:
10-
- secure: gZdvTl4i1QfHQaCUPcVpnLtlrsE4WldSm99AD9C9jiMgjlzhhI4kQmIhssNFhA1BWDW6qDazrKnw4ZT1GA/rlmGSpLxs2lfBNTjPF0CJMVSTEQ1OaFcDGajziTTCSMh7jDml1/CFHuGSc+rS4bNv5wu0bj+pz3ZSRSuB7Vgoa0aRD8JQKc+phnIoXMCCfIh9vxlXWvO9mDMoR84/B35/gN/vWIi3+uuHgvvdKMK8qBbJ0ne25kOIA5CpXzJmOBFHCGblVQM4+AiTWvWtoXJjMcJXn9HZ2g3HWhrnixG07Ee1RrjUPo25tsxrBowHSGq9Bbo+jzmOmx03CRnCBHyXk6e12MXrfVFWRdmFaf7Sl/RBlz8Y2BRgktp8ihB6JQmjNuRptE4RdnWn6CU9liSQ5nzzGEl2ZtBrzN9GR3qyhq5W9e09v93MZfBr0svp/rtBoqDANfkpxvmWqtgO3fjN1fdf092sEcQfq3d7e6NaLSWKkI6V9wJnJ9UulPDAaqGVm8RrA9b0vJR6ouCf5ChZgYirz6LW5uPpMkf+cjESU9JxnX9xVB8tfPSoNrPKolRC/WRZ8gPbRmx0vF4wrDk8z9Fks5nHGwDsPdYe60Qe8m6ZclncCkpUzy2yAZWe/kiDaseOwNbSqEUZW80hLyHpuGi1IFpGBQfc8mYMPvqOHa8=
11-
128
script:
13-
- cargo build --verbose
14-
- cargo test --verbose
15-
- cargo doc
16-
17-
after_success: '[ $TRAVIS_OS_NAME == linux ] && [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] &&
18-
echo "<meta http-equiv=refresh content=0;url=i2cdev/index.html>" > target/doc/index.html
19-
&& sudo pip install ghp-import && ghp-import -n target/doc && git push -fq https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git
20-
gh-pages'
21-
22-
notifications:
23-
webhooks: http://rust-embedded-bot.herokuapp.com/travis
9+
- cargo build --verbose
10+
- cargo test --verbose

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
name = "i2cdev"
44
build = "build.rs"
5-
version = "0.3.1"
5+
version = "0.3.2"
66
authors = ["Paul Osborne <[email protected]>"]
77
license = "MIT/Apache-2.0"
88
repository = "https://github.com/rust-embedded/rust-i2cdev"
@@ -15,14 +15,14 @@ https://www.kernel.org/doc/Documentation/i2c/dev-interface
1515
"""
1616

1717
[dependencies]
18-
libc = "^0.2.7"
19-
bitflags = "^0.5.0"
20-
byteorder = "^0.4.2"
21-
nix = "^0.6.0"
18+
libc = "0.2"
19+
bitflags = "1"
20+
byteorder = "1"
21+
nix = "0.10"
2222

2323
[dev-dependencies]
24-
docopt = "^0.6.78"
25-
skeptic = "^0.5"
24+
docopt = "0.8"
25+
skeptic = "0.13"
2626

2727
[build-dependencies]
28-
skeptic = "^0.5"
28+
skeptic = "0.13"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Rust I2cdev
55
[![Version](https://img.shields.io/crates/v/i2cdev.svg)](https://crates.io/crates/i2cdev)
66
[![License](https://img.shields.io/crates/l/i2cdev.svg)](https://github.com/rust-embedded/rust-i2cdev/blob/master/README.md#license)
77

8-
[Documentation](https://rust-embedded.github.io/rust-i2cdev)
8+
[Documentation](https://docs.rs/i2cdev)
99

1010
The Rust `i2cdev` crate seeks to provide full access to the Linux i2cdev
1111
driver interface in Rust without the need to wrap any C code or directly make
@@ -26,7 +26,7 @@ functions (read/write) which are done via the Read/Write traits (if
2626
you actually want to use the Wii Nunchuck you should use
2727
[`i2cdev::sensors::nunchuck::Nunchuck`][nunchuck]:
2828

29-
```rust,no_run
29+
```rust,no_run,skeptic-template
3030
extern crate i2cdev;
3131
3232
use std::thread;

src/ffi.rs

Lines changed: 58 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ use byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt};
1919
pub type I2CError = nix::Error;
2020

2121
bitflags! {
22-
flags I2CMsgFlags: u16 {
22+
struct I2CMsgFlags: u16 {
2323
/// this is a ten bit chip address
24-
const I2C_M_TEN = 0x0010,
24+
const I2C_M_TEN = 0x0010;
2525
/// read data, from slave to master
26-
const I2C_M_RD = 0x0001,
26+
const I2C_M_RD = 0x0001;
2727
/// if I2C_FUNC_PROTOCOL_MANGLING
28-
const I2C_M_STOP = 0x8000,
28+
const I2C_M_STOP = 0x8000;
2929
/// if I2C_FUNC_NOSTART
30-
const I2C_M_NOSTART = 0x4000,
30+
const I2C_M_NOSTART = 0x4000;
3131
/// if I2C_FUNC_PROTOCOL_MANGLING
32-
const I2C_M_REV_DIR_ADDR = 0x2000,
32+
const I2C_M_REV_DIR_ADDR = 0x2000;
3333
/// if I2C_FUNC_PROTOCOL_MANGLING
34-
const I2C_M_IGNORE_NAK = 0x1000,
34+
const I2C_M_IGNORE_NAK = 0x1000;
3535
/// if I2C_FUNC_PROTOCOL_MANGLING
36-
const I2C_M_NO_RD_ACK = 0x0800,
36+
const I2C_M_NO_RD_ACK = 0x0800;
3737
/// length will be first received byte
38-
const I2C_M_RECV_LEN = 0x0400,
38+
const I2C_M_RECV_LEN = 0x0400;
3939
}
4040
}
4141

@@ -52,44 +52,44 @@ struct i2c_msg {
5252
}
5353

5454
bitflags! {
55-
flags I2CFunctions: u32 {
56-
const I2C_FUNC_I2C = 0x00000001,
57-
const I2C_FUNC_10BIT_ADDR = 0x00000002,
58-
const I2C_FUNC_PROTOCOL_MANGLING = 0x00000004, /* I2C_M_IGNORE_NAK etc. */
59-
const I2C_FUNC_SMBUS_PEC = 0x00000008,
60-
const I2C_FUNC_NOSTART = 0x00000010, /* I2C_M_NOSTART */
61-
const I2C_FUNC_SMBUS_BLOCK_PROC_CALL = 0x00008000, /* SMBus 2.0 */
62-
const I2C_FUNC_SMBUS_QUICK = 0x00010000,
63-
const I2C_FUNC_SMBUS_READ_BYTE = 0x00020000,
64-
const I2C_FUNC_SMBUS_WRITE_BYTE = 0x00040000,
65-
const I2C_FUNC_SMBUS_READ_BYTE_DATA = 0x00080000,
66-
const I2C_FUNC_SMBUS_WRITE_BYTE_DATA = 0x00100000,
67-
const I2C_FUNC_SMBUS_READ_WORD_DATA = 0x00200000,
68-
const I2C_FUNC_SMBUS_WRITE_WORD_DATA = 0x00400000,
69-
const I2C_FUNC_SMBUS_PROC_CALL = 0x00800000,
70-
const I2C_FUNC_SMBUS_READ_BLOCK_DATA = 0x01000000,
71-
const I2C_FUNC_SMBUS_WRITE_BLOCK_DATA = 0x02000000,
72-
const I2C_FUNC_SMBUS_READ_I2C_BLOCK = 0x04000000, /* I2C-like block xfer */
73-
const I2C_FUNC_SMBUS_WRITE_I2C_BLOCK = 0x08000000, /* w/ 1-byte reg. addr. */
74-
75-
const I2C_FUNC_SMBUS_BYTE = (I2C_FUNC_SMBUS_READ_BYTE.bits |
76-
I2C_FUNC_SMBUS_WRITE_BYTE.bits),
77-
const I2C_FUNC_SMBUS_BYTE_DATA = (I2C_FUNC_SMBUS_READ_BYTE_DATA.bits |
78-
I2C_FUNC_SMBUS_WRITE_BYTE_DATA.bits),
79-
const I2C_FUNC_SMBUS_WORD_DATA = (I2C_FUNC_SMBUS_READ_WORD_DATA.bits |
80-
I2C_FUNC_SMBUS_WRITE_WORD_DATA.bits),
81-
const I2C_FUNC_SMBUS_BLOCK_DATA = (I2C_FUNC_SMBUS_READ_BLOCK_DATA.bits |
82-
I2C_FUNC_SMBUS_WRITE_BLOCK_DATA.bits),
83-
const I2C_FUNC_SMBUS_I2C_BLOCK = (I2C_FUNC_SMBUS_READ_I2C_BLOCK.bits |
84-
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK.bits),
85-
const I2C_FUNC_SMBUS_EMUL = (I2C_FUNC_SMBUS_QUICK.bits |
86-
I2C_FUNC_SMBUS_BYTE.bits |
87-
I2C_FUNC_SMBUS_BYTE_DATA.bits |
88-
I2C_FUNC_SMBUS_WORD_DATA.bits |
89-
I2C_FUNC_SMBUS_PROC_CALL.bits |
90-
I2C_FUNC_SMBUS_WRITE_BLOCK_DATA.bits |
91-
I2C_FUNC_SMBUS_I2C_BLOCK.bits |
92-
I2C_FUNC_SMBUS_PEC.bits),
55+
struct I2CFunctions: u32 {
56+
const I2C_FUNC_I2C = 0x00000001;
57+
const I2C_FUNC_10BIT_ADDR = 0x00000002;
58+
const I2C_FUNC_PROTOCOL_MANGLING = 0x00000004; /* I2C_M_IGNORE_NAK etc. */
59+
const I2C_FUNC_SMBUS_PEC = 0x00000008;
60+
const I2C_FUNC_NOSTART = 0x00000010; /* I2C_M_NOSTART */
61+
const I2C_FUNC_SMBUS_BLOCK_PROC_CALL = 0x00008000; /* SMBus 2.0 */
62+
const I2C_FUNC_SMBUS_QUICK = 0x00010000;
63+
const I2C_FUNC_SMBUS_READ_BYTE = 0x00020000;
64+
const I2C_FUNC_SMBUS_WRITE_BYTE = 0x00040000;
65+
const I2C_FUNC_SMBUS_READ_BYTE_DATA = 0x00080000;
66+
const I2C_FUNC_SMBUS_WRITE_BYTE_DATA = 0x00100000;
67+
const I2C_FUNC_SMBUS_READ_WORD_DATA = 0x00200000;
68+
const I2C_FUNC_SMBUS_WRITE_WORD_DATA = 0x00400000;
69+
const I2C_FUNC_SMBUS_PROC_CALL = 0x00800000;
70+
const I2C_FUNC_SMBUS_READ_BLOCK_DATA = 0x01000000;
71+
const I2C_FUNC_SMBUS_WRITE_BLOCK_DATA = 0x02000000;
72+
const I2C_FUNC_SMBUS_READ_I2C_BLOCK = 0x04000000; /* I2C-like block xfer */
73+
const I2C_FUNC_SMBUS_WRITE_I2C_BLOCK = 0x08000000; /* w/ 1-byte reg. addr. */
74+
75+
const I2C_FUNC_SMBUS_BYTE = (I2CFunctions::I2C_FUNC_SMBUS_READ_BYTE.bits |
76+
I2CFunctions::I2C_FUNC_SMBUS_WRITE_BYTE.bits);
77+
const I2C_FUNC_SMBUS_BYTE_DATA = (I2CFunctions::I2C_FUNC_SMBUS_READ_BYTE_DATA.bits |
78+
I2CFunctions::I2C_FUNC_SMBUS_WRITE_BYTE_DATA.bits);
79+
const I2C_FUNC_SMBUS_WORD_DATA = (I2CFunctions::I2C_FUNC_SMBUS_READ_WORD_DATA.bits |
80+
I2CFunctions::I2C_FUNC_SMBUS_WRITE_WORD_DATA.bits);
81+
const I2C_FUNC_SMBUS_BLOCK_DATA = (I2CFunctions::I2C_FUNC_SMBUS_READ_BLOCK_DATA.bits |
82+
I2CFunctions::I2C_FUNC_SMBUS_WRITE_BLOCK_DATA.bits);
83+
const I2C_FUNC_SMBUS_I2C_BLOCK = (I2CFunctions::I2C_FUNC_SMBUS_READ_I2C_BLOCK.bits |
84+
I2CFunctions::I2C_FUNC_SMBUS_WRITE_I2C_BLOCK.bits);
85+
const I2C_FUNC_SMBUS_EMUL = (I2CFunctions::I2C_FUNC_SMBUS_QUICK.bits |
86+
I2CFunctions::I2C_FUNC_SMBUS_BYTE.bits |
87+
I2CFunctions::I2C_FUNC_SMBUS_BYTE_DATA.bits |
88+
I2CFunctions::I2C_FUNC_SMBUS_WORD_DATA.bits |
89+
I2CFunctions::I2C_FUNC_SMBUS_PROC_CALL.bits |
90+
I2CFunctions::I2C_FUNC_SMBUS_WRITE_BLOCK_DATA.bits |
91+
I2CFunctions::I2C_FUNC_SMBUS_I2C_BLOCK.bits |
92+
I2CFunctions::I2C_FUNC_SMBUS_PEC.bits);
9393
}
9494
}
9595

@@ -151,7 +151,7 @@ const I2C_RDRW_IOCTL_MAX_MSGS: u8 = 42;
151151

152152
/// This is the structure as used in the I2C_SMBUS ioctl call
153153
#[repr(C)]
154-
struct i2c_smbus_ioctl_data {
154+
pub struct i2c_smbus_ioctl_data {
155155
// __u8 read_write;
156156
read_write: u8,
157157
// __u8 command;
@@ -171,15 +171,18 @@ struct i2c_rdwr_ioctl_data {
171171
nmsgs: u32,
172172
}
173173

174-
ioctl!(bad ioctl_set_i2c_slave_address with I2C_SLAVE);
175-
ioctl!(bad ioctl_i2c_smbus with I2C_SMBUS);
174+
mod ioctl {
175+
use super::{I2C_SLAVE, I2C_SMBUS};
176+
pub use super::i2c_smbus_ioctl_data;
177+
178+
ioctl!(bad write_int set_i2c_slave_address with I2C_SLAVE);
179+
ioctl!(bad write_ptr i2c_smbus with I2C_SMBUS; i2c_smbus_ioctl_data);
180+
}
181+
176182

177183
pub fn i2c_set_slave_address(fd: RawFd, slave_address: u16) -> Result<(), nix::Error> {
178184
try!(unsafe {
179-
// NOTE: the generated ioctl call expected as pointer to a u8 but
180-
// we just want to provide the u8 directly, so we just cast to a pointer.
181-
// This is correct behavior.
182-
ioctl_set_i2c_slave_address(fd, slave_address as *mut u8)
185+
ioctl::set_i2c_slave_address(fd, slave_address as i32)
183186
});
184187
Ok(())
185188
}
@@ -198,8 +201,7 @@ unsafe fn i2c_smbus_access(fd: RawFd,
198201
};
199202

200203
// remove type information
201-
let p_args: *mut u8 = mem::transmute(&mut args);
202-
ioctl_i2c_smbus(fd, p_args).map(drop)
204+
ioctl::i2c_smbus(fd, &mut args).map(drop)
203205
}
204206

205207
#[inline]

src/linux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl From<LinuxI2CError> for io::Error {
4848
LinuxI2CError::Nix(e) => {
4949
match e {
5050
nix::Error::Sys(e) => io::Error::from_raw_os_error(e as i32),
51-
nix::Error::InvalidPath => {
51+
e => {
5252
io::Error::new(io::ErrorKind::InvalidInput, format!("{:?}", e))
5353
}
5454
}

0 commit comments

Comments
 (0)