-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This idea comes from issue #14 - Rename `Attribute::new()` to `Attribute::from_sys_class()` - Add `Attribute::from_path()` - Add `Attribute::from_path_with_discriminator()` - Add example for `Attribute::from_path_with_discriminator()`
- Loading branch information
Showing
12 changed files
with
174 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[target.armv5te-unknown-linux-gnueabi] | ||
linker = "/usr/bin/arm-linux-gnueabi-gcc" | ||
|
||
[term] | ||
color = "always" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "attributes" | ||
version = "0.1.0" | ||
authors = ["Lars Westermann <lars.westermann@tu-dresden.de>"] | ||
|
||
[dependencies] | ||
ev3dev-lang-rust = { path = "../.."} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.PHONY: all clean | ||
|
||
all: | ||
docker run --rm -v $(PWD)/../../:/ev3dev-lang-rust/ -w /ev3dev-lang-rust/examples/attributes pixix4/ev3dev-rust cargo build --release --target armv5te-unknown-linux-gnueabi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# `Attribute` example | ||
|
||
Simple example for `Attribute` usage | ||
|
||
```bash | ||
make | ||
# Binary: ../../target/armv5te-unknown-linux-gnueabi/release/attributes | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
extern crate ev3dev_lang_rust; | ||
|
||
use ev3dev_lang_rust::Attribute; | ||
use ev3dev_lang_rust::Ev3Result; | ||
|
||
fn main() -> Ev3Result<()> { | ||
// Get value0 of first connected color sensor. | ||
let color_sensor_value = Attribute::from_path_with_discriminator( | ||
"/sys/class/lego-sensor", | ||
"value0", | ||
"driver_name", | ||
"lego-ev3-color", | ||
)?; | ||
|
||
// Get raw rotation count of motor in port `A`. | ||
// See https://github.com/ev3dev/ev3dev/wiki/Internals:-ev3dev-stretch for more infomation. | ||
let rotation_count = Attribute::from_path_with_discriminator( | ||
"/sys/bus/iio/devices", | ||
"in_count0_raw", | ||
"name", | ||
"ev3-tacho", | ||
)?; | ||
|
||
loop { | ||
println!( | ||
"value0 of color sensor: {}", | ||
color_sensor_value.get::<i32>()? | ||
); | ||
println!("Raw rotation count: {}", rotation_count.get::<i32>()?); | ||
|
||
std::thread::sleep(std::time::Duration::from_secs(1)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters