custom_attributes/
custom-attributes.rs1extern crate ev3dev_lang_rust;
2
3use ev3dev_lang_rust::Attribute;
4use ev3dev_lang_rust::Ev3Result;
5
6fn main() -> Ev3Result<()> {
7 let color_sensor_value = Attribute::from_path_with_discriminator(
9 "/sys/class/lego-sensor",
10 "value0",
11 "driver_name",
12 "lego-ev3-color",
13 )?;
14
15 let rotation_count = Attribute::from_path_with_discriminator(
18 "/sys/bus/iio/devices",
19 "in_count0_raw",
20 "name",
21 "ev3-tacho",
22 )?;
23
24 loop {
25 println!(
26 "value0 of color sensor: {}",
27 color_sensor_value.get::<i32>()?
28 );
29 println!("Raw rotation count: {}", rotation_count.get::<i32>()?);
30
31 std::thread::sleep(std::time::Duration::from_secs(1));
32 }
33}