Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ impl Attribute {
})
}

/// Returns the current content of the wrapped file.
pub fn get_bytes(&self) -> Ev3Result<Vec<u8>> {
let mut value: Vec<u8> = Vec::new();
let mut file = self.file.lock().unwrap();
file.seek(SeekFrom::Start(0))?;
file.read_to_end(&mut value)?;
Ok(value)
}

/// Returns the current value of the wrapped file.
fn get_str(&self) -> Ev3Result<String> {
let mut value = String::new();
Expand Down
4 changes: 2 additions & 2 deletions src/sensors/sensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::{Device, Ev3Result};
pub trait Sensor: Device {
/// Reading the file will give the unscaled raw values in the `value<N>` attributes.
/// Use `bin_data_format`, `num_values` and the individual sensor documentation to determine how to interpret the data.
fn get_bin_data(&self) -> Ev3Result<String> {
self.get_attribute("bin_data").get()
fn get_bin_data(&self) -> Ev3Result<Vec<u8>> {
self.get_attribute("bin_data").get_bytes()
}

/// Returns the format of the values in `bin_data` for the current mode. Possible values are:
Expand Down