pixix4/ev3dev-lang-rust

Add support for getting "raw" data

Closed this issue · 1 comments

I could be wrong but currently I do not think it is possible to get the data described here through this library. Main use case would be to get a more accurate wheel position.

Cause this is an advanced feature I did not add an explicit wrapper. But I opened the Attribute module for arbitrary paths. With this module you can easily take advantage of the file handler caching and typed accessor methods. There are two usage options.

First you can use this module with an explicit path:

use ev3dev_lang_rust::Attribute;

let a = Attribute:: from_path("/sys/bus/iio/devices/iio:device1/in_count0_raw")?;
println!("{}", a.get::<i32>()?);

Second you can use a create method with a discriminator. This method helps to find the right subdirectory within a root_path:

use ev3dev_lang_rust::Attribute;

let a = Attribute::from_path_with_discriminator(
        "/sys/bus/iio/devices", // root_path
        "in_count0_raw",        // attribute_path
        "name",                 // discriminator_path
        "ev3-tacho"             // discriminator_value
)?;
println!("{}", a.get::<i32>()?);

More details for this variant can be found in the docs and at the example.