fpagliughi / rust-industrial-io

Rust interface to the Linux Industrial I/O subsystem
MIT License
45 stars 21 forks source link

Extended error handling for device sample rates #10

Closed Funky185540 closed 3 years ago

Funky185540 commented 3 years ago

Setting the sample rate for a device isn't a strictly normed operation in IIO. The examples previously relied on the trigger for a device to expose the sampling_frequency attribute that sets the sample frequency. However, this assumption doesn't hold for all sensors in the kernel. Some expose the sampling_frequency attribute on the device itself instead of the trigger.

These patches add some error handling to take care of these cases. If the sampling_frequency attribute can't be found on the device or its respective trigger, an error is thrown.

fpagliughi commented 3 years ago

Looks good for now. I may tweak all the examples to have more control of things at the command line (like being explicit about which device to set the trigger)