Skip to content

Commit

Permalink
Fix spelling errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pixix4 committed Jan 30, 2022
1 parent f31b658 commit aa02bf3
Show file tree
Hide file tree
Showing 20 changed files with 82 additions and 77 deletions.
9 changes: 9 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
[target.armv5te-unknown-linux-gnueabi]
linker = "/usr/bin/arm-linux-gnueabi-gcc"

[target.armv5te-unknown-linux-musleabi]
linker = "rust-lld"

[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "vendor"
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ev3dev-lang-rust"
version = "0.11.1"
version = "0.12.0"
edition = "2021"
authors = ["Lars Westermann <rust@lars-westermann.de>"]

Expand Down
39 changes: 20 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
build-example-attributes:
docker run --rm -v $(PWD):/ev3dev-lang-rust/ -w /ev3dev-lang-rust/examples/attributes pixix4/ev3dev-rust /bin/bash -c "cargo build --release --target armv5te-unknown-linux-gnueabi && /usr/bin/arm-linux-gnueabi-strip /ev3dev-lang-rust/target/armv5te-unknown-linux-gnueabi/release/attributes"
all: build strip

build-example-buttons:
docker run --rm -v $(PWD):/ev3dev-lang-rust/ -w /ev3dev-lang-rust/examples/buttons pixix4/ev3dev-rust /bin/bash -c "cargo build --release --target armv5te-unknown-linux-gnueabi && /usr/bin/arm-linux-gnueabi-strip /ev3dev-lang-rust/target/armv5te-unknown-linux-gnueabi/release/buttons"
build:
docker run --rm -v $(PWD):/build -w /build pixix4/ev3dev-rust:latest \
cargo build --release --examples --target armv5te-unknown-linux-musleabi

build-example-color-sensor:
docker run --rm -v $(PWD):/ev3dev-lang-rust/ -w /ev3dev-lang-rust/examples/color-sensor pixix4/ev3dev-rust /bin/bash -c "cargo build --release --target armv5te-unknown-linux-gnueabi && /usr/bin/arm-linux-gnueabi-strip /ev3dev-lang-rust/target/armv5te-unknown-linux-gnueabi/release/color-sensor"
strip: strip-buttons strip-color-sensor strip-custom-attributes strip-infrared-sensor strip-motors

build-example-infrared-sensor:
docker run --rm -v $(PWD):/ev3dev-lang-rust/ -w /ev3dev-lang-rust/examples/infrared-sensor pixix4/ev3dev-rust /bin/bash -c "cargo build --release --target armv5te-unknown-linux-gnueabi && /usr/bin/arm-linux-gnueabi-strip /ev3dev-lang-rust/target/armv5te-unknown-linux-gnueabi/release/infrared-sensor"

build-example-motors:
docker run --rm -v $(PWD):/ev3dev-lang-rust/ -w /ev3dev-lang-rust/examples/motors pixix4/ev3dev-rust /bin/bash -c "cargo build --release --target armv5te-unknown-linux-gnueabi && /usr/bin/arm-linux-gnueabi-strip /ev3dev-lang-rust/target/armv5te-unknown-linux-gnueabi/release/motors"

build-example-screen:
docker run --rm -v $(PWD):/ev3dev-lang-rust/ -w /ev3dev-lang-rust/examples/screen pixix4/ev3dev-rust /bin/bash -c "cargo build --release --target armv5te-unknown-linux-gnueabi && /usr/bin/arm-linux-gnueabi-strip /ev3dev-lang-rust/target/armv5te-unknown-linux-gnueabi/release/screen"

build-examples: build-example-attributes build-example-buttons build-example-color-sensor build-example-infrared-sensor build-example-screen

clean:
cargo clean
strip-buttons:
docker run --rm -v $(PWD):/build -w /build pixix4/ev3dev-rust:latest \
arm-linux-gnueabi-strip /build/target/armv5te-unknown-linux-musleabi/release/examples/buttons
strip-color-sensor:
docker run --rm -v $(PWD):/build -w /build pixix4/ev3dev-rust:latest \
arm-linux-gnueabi-strip /build/target/armv5te-unknown-linux-musleabi/release/examples/color-sensor
strip-custom-attributes:
docker run --rm -v $(PWD):/build -w /build pixix4/ev3dev-rust:latest \
arm-linux-gnueabi-strip /build/target/armv5te-unknown-linux-musleabi/release/examples/custom-attributes
strip-infrared-sensor:
docker run --rm -v $(PWD):/build -w /build pixix4/ev3dev-rust:latest \
arm-linux-gnueabi-strip /build/target/armv5te-unknown-linux-musleabi/release/examples/infrared-sensor
strip-motors:
docker run --rm -v $(PWD):/build -w /build pixix4/ev3dev-rust:latest \
arm-linux-gnueabi-strip /build/target/armv5te-unknown-linux-musleabi/release/examples/motors
23 changes: 9 additions & 14 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
FROM debian:stretch
FROM debian:stretch-slim

RUN dpkg --add-architecture armel
RUN apt update

# Fix debian package alias
RUN apt-get update
RUN sed -i "s#deb http://security.debian.org/debian-security stretch/updates main#deb http://deb.debian.org/debian-security stretch/updates main#g" /etc/apt/sources.list

# Install curl for rust installation
# Install g++ as buildscript compiler
# Install g++-arm-linux-gnueabi as cross compiler
RUN apt --yes install curl g++ g++-arm-linux-gnueabi crossbuild-essential-armel
RUN apt-get --yes install curl cmake pkg-config clang g++ g++-arm-linux-gnueabi crossbuild-essential-armel libssl-dev libssl-dev:armel libclang-dev \
&& rm -rf /var/lib/apt/lists/*


# Instull rust for host platform
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

ENV PATH "$PATH:/root/.cargo/bin"

# Add stdlib for target platform
RUN rustup target add armv5te-unknown-linux-gnueabi

# docker build . -t pixix4/ev3dev-rust --no-cache
RUN rustup target add armv5te-unknown-linux-musleabi armv5te-unknown-linux-gnueabi

# docker run -it --rm -v $PWD:/build/ -w /build pixix4/ev3dev-rust
# cargo build --release --target armv5te-unknown-linux-gnueabi
ENV PKG_CONFIG_SYSROOT_DIR /usr/arm-linux-gnueabi/
ENV CC_armv5te_unknown_linux_gnueabi arm-linux-gnueabi-gcc
ENV CXX_armv5te_unknown_linux_gnueabi arm-linux-gnueabi-g++
8 changes: 4 additions & 4 deletions src/attriute.rs → src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl Attribute {
})
}

/// Create a new `Attribute` instance that wrappes
/// Create a new `Attribute` instance that wrap's
/// the file `/sys/class/{class_name}/{name}{attribute_name}`.
pub fn from_sys_class(
class_name: &str,
Expand Down Expand Up @@ -71,7 +71,7 @@ impl Attribute {
/// println!("value0 of color sensor: {}", color_sensor_value.get::<i32>()?);
///
/// // Get raw rotation count of motor in port `A`.
/// // See https://github.com/ev3dev/ev3dev/wiki/Internals:-ev3dev-stretch for more infomation.
/// // See https://github.com/ev3dev/ev3dev/wiki/Internals:-ev3dev-stretch for more information.
/// let rotation_count = Attribute::from_path_with_discriminator(
/// "/sys/bus/iio/devices",
/// "in_count0_raw",
Expand Down Expand Up @@ -105,7 +105,7 @@ impl Attribute {

Err(Ev3Error::InternalError {
msg: format!(
"Attribute `{}` at root path `{}` coult not be found!",
"Attribute `{}` at root path `{}` could not be found!",
attribute_path, root_path
),
})
Expand Down Expand Up @@ -165,7 +165,7 @@ impl Attribute {
}

/// Returns a string vector representation of the wrapped file.
/// The file value is splitet at whitespaces.
/// The file value is splitted at whitespace's.
pub fn get_vec(&self) -> Ev3Result<Vec<String>> {
let value = self.get_str()?;
let vec = value
Expand Down
8 changes: 4 additions & 4 deletions src/buttons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct FileMapEntry {
pub file: File,
pub buffer_cache: [u8; KEY_BUF_LEN],
}
// Manuelly implement Debug cause `buffer_cache` does not implement Debug.
// Manually implement Debug cause `buffer_cache` does not implement Debug.
impl fmt::Debug for FileMapEntry {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("FileMapEntry")
Expand Down Expand Up @@ -103,14 +103,14 @@ impl ButtonFileHandler {
self.pressed_buttons.contains(name)
}

/// Check for currenly pressed buttons. If the new state differs from the
/// Check for currently pressed buttons. If the new state differs from the
/// old state, call the appropriate button event handlers.
fn process(&mut self) {
for entry in self.file_map.values_mut() {
unsafe {
libc::ioctl(
entry.file.as_raw_fd(),
EVIOCGKEY.into(),
(EVIOCGKEY as i32).try_into().unwrap(),
&mut entry.buffer_cache,
);
}
Expand Down Expand Up @@ -185,7 +185,7 @@ impl Ev3Button {
})
}

/// Check for currenly pressed buttons. If the new state differs from the
/// Check for currently pressed buttons. If the new state differs from the
/// old state, call the appropriate button event handlers.
pub fn process(&self) {
self.button_handler.borrow_mut().process()
Expand Down
2 changes: 1 addition & 1 deletion src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl Driver {

Err(Ev3Error::NotConnected {
device: format!("{:?}", driver_name_vec),
port: Some(port.address()),
port: Some(port_address),
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/led.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! The leds on top of the EV3 brick.
//! The led's on top of the EV3 brick.
use std::fs;

Expand All @@ -7,7 +7,7 @@ use crate::{utils::OrErr, Attribute, Ev3Result};
/// Color type.
pub type Color = (u8, u8);

/// The leds on top of the EV3 brick.
/// The led's on top of the EV3 brick.
#[derive(Debug, Clone)]
pub struct Led {
left_red: Attribute,
Expand Down
7 changes: 3 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//! // Run motor.
//! large_motor.set_duty_cycle_sp(50)?;
//!
//! // Find color sensor. Always returns the first recognised one.
//! // Find color sensor. Always returns the first recognized one.
//! let color_sensor = ColorSensor::find()?;
//!
//! // Switch to rgb mode.
Expand All @@ -46,8 +46,8 @@ extern crate libc;
#[macro_use]
mod findable;

mod attriute;
pub use attriute::Attribute;
mod attribute;
pub use attribute::Attribute;
mod driver;
pub use driver::Driver;
mod device;
Expand All @@ -56,7 +56,6 @@ pub use device::Device;
mod utils;
pub use utils::{Ev3Error, Ev3Result, Port};

#[cfg(target_os = "linux")]
pub mod wait;

pub mod motors;
Expand Down
4 changes: 1 addition & 3 deletions src/motors/large_motor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use super::MotorPort;
#[cfg(target_os = "linux")]
use crate::wait;
use crate::{Attribute, Device, Driver, Ev3Error, Ev3Result};
use crate::{wait, Attribute, Device, Driver, Ev3Error, Ev3Result};
use std::time::Duration;

/// EV3/NXT large servo motor
Expand Down
4 changes: 1 addition & 3 deletions src/motors/medium_motor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use super::MotorPort;
#[cfg(target_os = "linux")]
use crate::wait;
use crate::{Attribute, Device, Driver, Ev3Error, Ev3Result};
use crate::{wait, Attribute, Device, Driver, Ev3Error, Ev3Result};
use std::time::Duration;

/// EV3 medium servo motor
Expand Down
8 changes: 4 additions & 4 deletions src/motors/servo_motor_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ macro_rules! servo_motor {

/// Returns the current mid pulse setpoint.
/// Used to set the pulse size in milliseconds for the signal
/// that tells the servo to drive to the miniumum (counter-clockwise) position_sp.
/// that tells the servo to drive to the minimum (counter-clockwise) position_sp.
/// Default value is 600.
/// Valid values are 300 to 700.
/// You must write to the position_sp attribute for changes to this attribute to take effect.
Expand All @@ -59,7 +59,7 @@ macro_rules! servo_motor {

/// Sets the mid pulse setpoint.
/// Used to set the pulse size in milliseconds for the signal
/// that tells the servo to drive to the miniumum (counter-clockwise) position_sp.
/// that tells the servo to drive to the minimum (counter-clockwise) position_sp.
/// Default value is 600.
/// Valid values are 300 to 700.
/// You must write to the position_sp attribute for changes to this attribute to take effect.
Expand All @@ -69,15 +69,15 @@ macro_rules! servo_motor {

/// Returns the current min pulse setpoint.
/// Used to set the pulse size in milliseconds for the signal
/// that tells the servo to drive to the miniumum (counter-clockwise) position_sp.
/// that tells the servo to drive to the minimum (counter-clockwise) position_sp.
/// Default value is 600. Valid values are 300 to 700.
/// You must write to the position_sp attribute for changes to this attribute to take effect.
pub fn get_min_pulse_sp(&self) -> Ev3Result<i32> {
self.get_attribute("min_pulse_sp").get()
}
/// Sets the min pulse setpoint.
/// Used to set the pulse size in milliseconds for the signal
/// that tells the servo to drive to the miniumum (counter-clockwise) position_sp.
/// that tells the servo to drive to the minimum (counter-clockwise) position_sp.
/// Default value is 600. Valid values are 300 to 700.
/// You must write to the position_sp attribute for changes to this attribute to take effect.
pub fn set_min_pulse_sp(&self, min_pulse_sp: i32) -> Ev3Result<()> {
Expand Down
4 changes: 2 additions & 2 deletions src/motors/tacho_motor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl TachoMotor {

/// Returns the number of tacho counts in the full travel of the motor.
///
/// When combined with the count_per_m atribute,
/// When combined with the count_per_m attribute,
/// you can use this value to calculate the maximum travel distance of the motor.
/// (linear motors only)
pub fn get_full_travel_count(&self) -> Ev3Result<i32> {
Expand Down Expand Up @@ -910,7 +910,7 @@ impl TachoMotor {

/// Wait until the motor is not moving or the timeout is reached.
///
/// This is euqal to `wait_while(STATE_RUNNING, timeout)`.
/// This is equal to `wait_while(STATE_RUNNING, timeout)`.
/// If the `timeout` is `None` it will wait an infinite time.
///
/// # Example
Expand Down
8 changes: 2 additions & 6 deletions src/motors/tacho_motor_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ macro_rules! tacho_motor {

/// Returns the number of tacho counts in the full travel of the motor.
///
/// When combined with the count_per_m atribute,
/// When combined with the count_per_m attribute,
/// you can use this value to calculate the maximum travel distance of the motor.
/// (linear motors only)
pub fn get_full_travel_count(&self) -> Ev3Result<i32> {
Expand Down Expand Up @@ -620,7 +620,6 @@ macro_rules! tacho_motor {
/// # Ok(())
/// # }
/// ```
#[cfg(target_os = "linux")]
pub fn wait<F>(&self, cond: F, timeout: Option<Duration>) -> bool
where
F: Fn() -> bool,
Expand Down Expand Up @@ -651,7 +650,6 @@ macro_rules! tacho_motor {
/// # Ok(())
/// # }
/// ```
#[cfg(target_os = "linux")]
pub fn wait_while(&self, state: &str, timeout: Option<Duration>) -> bool {
let cond = || {
self.get_state()
Expand Down Expand Up @@ -684,7 +682,6 @@ macro_rules! tacho_motor {
/// # Ok(())
/// # }
/// ```
#[cfg(target_os = "linux")]
pub fn wait_until(&self, state: &str, timeout: Option<Duration>) -> bool {
let cond = || {
self.get_state()
Expand All @@ -697,7 +694,7 @@ macro_rules! tacho_motor {

/// Wait until the motor is not moving or the timeout is reached.
///
/// This is euqal to `wait_while(STATE_RUNNING, timeout)`.
/// This is equal to `wait_while(STATE_RUNNING, timeout)`.
/// If the `timeout` is `None` it will wait an infinite time.
///
/// # Example
Expand All @@ -718,7 +715,6 @@ macro_rules! tacho_motor {
/// # Ok(())
/// # }
/// ```
#[cfg(target_os = "linux")]
pub fn wait_until_not_moving(&self, timeout: Option<Duration>) -> bool {
self.wait_while(Self::STATE_RUNNING, timeout)
}
Expand Down
4 changes: 2 additions & 2 deletions src/screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use image::{Rgb, RgbImage};
use crate::Ev3Result;

/// Represents the device screen.
/// Advanced drawing operations can be perfomed with the `imageproc` crate.
/// Advanced drawing operations can be performed with the `imageproc` crate.
#[cfg(feature = "screen")]
#[derive(Debug)]
pub struct Screen {
/// Direct reference to the framebuffer
pub buffer: Framebuffer,
/// Convinience layer to access the framebuffer
/// Convenience layer to access the framebuffer
/// For drawing operations the `imageproc` crate can be used.
pub image: RgbImage,
}
Expand Down
2 changes: 1 addition & 1 deletion src/sensors/color_sensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl ColorSensor {
self.get_value2()
}

/// Red, green and blue componets of the detected color, each in the range 0-1020
/// Red, green and blue components of the detected color, each in the range 0-1020
pub fn get_rgb(&self) -> Ev3Result<(i32, i32, i32)> {
let red = self.get_red()?;
let green = self.get_green()?;
Expand Down
6 changes: 3 additions & 3 deletions src/sensors/infrared_sensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl InfraredSensor {
"lego-sensor",
["lego-ev3-ir"],
SensorPort,
"InfraredrSensor",
"InfraredSensor",
"in"
);

Expand Down Expand Up @@ -101,7 +101,7 @@ pub struct RemoteControl {
helper: Rc<RefCell<RemoteControlHelper>>,
}

// Manuelly implement Debug cause `buffer_cache` does not implement Debug.
// Manually implement Debug cause `buffer_cache` does not implement Debug.
impl fmt::Debug for RemoteControl {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RemoteControl")
Expand Down Expand Up @@ -148,7 +148,7 @@ impl RemoteControl {
self.helper.borrow().contains("beacon")
}

/// Check for currenly pressed buttons. If the new state differs from the
/// Check for currently pressed buttons. If the new state differs from the
/// old state, call the appropriate button event handlers.
pub fn process(&self) -> Ev3Result<()> {
let buttons = self.sensor.get_value(self.channel)?;
Expand Down
Loading

0 comments on commit aa02bf3

Please sign in to comment.