juliangaal / mpu6050

MPU6050 embedded-hal driver written in Rust
https://crates.io/crates/mpu6050
MIT License
50 stars 31 forks source link

error[E0277]: `mpu6050::RPReading` doesn't implement `std::fmt::Display` #4

Closed olegantonyan closed 5 years ago

olegantonyan commented 5 years ago

Trying to build an example (https://github.com/juliangaal/mpu6050/blob/dev/examples/linux.rs) for aarch64-unknown-linux-gnu Cargo.toml

[dependencies]
mpu6050 = "*"
i2cdev = "*"
linux-embedded-hal = "*"
embedded-hal = "*"

.cargo/config

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

[target.arm-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"

rustup show

Default host: x86_64-unknown-linux-gnu

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)

installed targets for active toolchain
--------------------------------------

aarch64-unknown-linux-gnu
arm-unknown-linux-gnueabihf
x86_64-unknown-linux-gnu

active toolchain
----------------

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.37.0-nightly (03ee55bb1 2019-06-01)

cargo build --release --target aarch64-unknown-linux-gnu

 error[E0277]: `mpu6050::RPReading` doesn't implement `std::fmt::Display`
  --> src/main.rs:22:29
   |
22 |         println!("r/p: {}", acc);
   |                             ^^^ `mpu6050::RPReading` cannot be formatted with the default formatter
   |
   = help: the trait `std::fmt::Display` is not implemented for `mpu6050::RPReading`
   = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
   = note: required by `std::fmt::Display::fmt`

error[E0277]: `mpu6050::RPReading` doesn't implement `std::fmt::Display`
  --> src/main.rs:26:33
   |
26 |         println!("r/p avg: {}", acc);
   |                                 ^^^ `mpu6050::RPReading` cannot be formatted with the default formatter
   |
   = help: the trait `std::fmt::Display` is not implemented for `mpu6050::RPReading`
   = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
   = note: required by `std::fmt::Display::fmt`

error[E0277]: `mpu6050::RotReading` doesn't implement `std::fmt::Display`
  --> src/main.rs:38:30
   |
38 |         println!("gyro: {}", gyro);
   |                              ^^^^ `mpu6050::RotReading` cannot be formatted with the default formatter
   |
   = help: the trait `std::fmt::Display` is not implemented for `mpu6050::RotReading`
   = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
   = note: required by `std::fmt::Display::fmt`

error[E0277]: `mpu6050::RotReading` doesn't implement `std::fmt::Display`
  --> src/main.rs:42:34
   |
42 |         println!("gyro avg: {}", gyro);
   |                                  ^^^^ `mpu6050::RotReading` cannot be formatted with the default formatter
   |
   = help: the trait `std::fmt::Display` is not implemented for `mpu6050::RotReading`
   = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
   = note: required by `std::fmt::Display::fmt`

error[E0277]: `mpu6050::RotReading` doesn't implement `std::fmt::Display`
  --> src/main.rs:46:29
   |
46 |         println!("acc: {}", acc);
   |                             ^^^ `mpu6050::RotReading` cannot be formatted with the default formatter
   |
   = help: the trait `std::fmt::Display` is not implemented for `mpu6050::RotReading`
   = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
   = note: required by `std::fmt::Display::fmt`

error[E0277]: `mpu6050::RotReading` doesn't implement `std::fmt::Display`
  --> src/main.rs:50:33
   |
50 |         println!("acc avg: {}", acc);
   |                                 ^^^ `mpu6050::RotReading` cannot be formatted with the default formatter
   |
   = help: the trait `std::fmt::Display` is not implemented for `mpu6050::RotReading`
   = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
   = note: required by `std::fmt::Display::fmt`
juliangaal commented 5 years ago

which branch are you on?

olegantonyan commented 5 years ago

I'm using crate https://crates.io/crates/mpu6050

juliangaal commented 5 years ago

Thanks for the pull request. I'm planning an important version bump towards the end of the week on crates.io, that will make your pull request unnecessary, as I moved everything to nalgebra, which overloads std::fmt::Display::fmt Until then, you could use the dev branch in your Cargo.toml with

mpu6050 = { git = "https://github.com/juliangaal/mpu6050/", branch = "dev" }

It should be good to go as is, although my testing isn't completed yet! I just compiled dev on my machine, for ARM, and it works. Don't forget to configure the linker!

If that's not an option (or the dev branch doesn't work quite right), use the crates version and either delete or fix the example (like in your pr).

Important The compilation may still fail because of a dependency, nix. It's fixed on dev, but not master.

juliangaal commented 5 years ago

Any updates?

olegantonyan commented 5 years ago

I resoled this by using {:?} formatting

juliangaal commented 5 years ago

But it compiled for arch? That's strange, because nix is an old version that doesn't compile for linux...I'll have a look at it. I'll tell you I give the crate a version and dependency version bump.

olegantonyan commented 5 years ago

Yes, it compiles for aarch64 linux and works on jetson nano board

juliangaal commented 5 years ago

I just updated the crate version to 0.1.3, thanks for your patience. This version doesn't change the API, but moves to nalgebra for all readings on the device.

Any other feedback? Thanks for your help

olegantonyan commented 5 years ago

0.1.3 also seems to work. thanks

juliangaal commented 5 years ago

great to hear, closing this issue now. Thanks