Crate hermes_five

Source
Expand description

HERMES-FIVE - The Rust Robotics & IoT Platform

Hermes-Five is an open-source IoT and Robotics programming framework - written in Rust.

Schema sample of blinking led using Arduino UNO

§Documentation

This is the API documentation.
To read more detailed explanations, visit the user documentation.
To see the code in action, visit the examples directory.

§Features

Hermes-Five is a Rust library designed to “remotely” control Arduino (or compatible) boards as well as all types of input/output devices (led, servo, button, sensors, etc.) connected to it.
It can be compared to Johnny-Five in the javascript ecosystem.

  • Define remotely controllable Board (Arduino currently)
  • Control boards though an IoProtocol connection (Serial for the moment)
  • Remote control all types of Devices such as Outputs (LED, servo, etc.) or Inputs (button, switch, sensors,
  • etc.) individually
  • Create and play Animation with auto-interpolate movements

If you wish to do the same with absolutely no code via a nice-and-shiny interface, please consult the Hermes-Studio project.

§Prerequisites

  • To run the examples provided, you will at least an Arduino board attached via the serial port of your computer (or the machine running your code).
  • StandardFirmataPlus.ino Arduino sketch MUST be installed on the board. This code is available by default in Arduino IDE under the Firmata samples sketch menu. Uploading the sketch to the board needs to be done once only.

§Getting Started

[dependencies]
hermes-five = "0.1.0"
  • Start writing your HERMES code: see the examples directory for more examples.

The following code demonstrates the simplest program we could imagine: blink the Arduino embedded led on pin 13.

use hermes_five::hardware::{Board, BoardEvent};
use hermes_five::devices::Led;

#[hermes_five::runtime]
async fn main() {

    // Register a new board.
    // (of type arduino + auto-detected serial port by default)
    let board = Board::run();

    // When board communication is ready:
    board.on(BoardEvent::OnReady, |board: Board| async move {

        // Register a LED on pin 13 (arduino embedded led).
        // Pin: 13; OFF by default
        let mut led = Led::new(&board, 13, false)?;

        // Blinks the LED every 500ms: indefinitely.
        led.blink(500);

        Ok(())
    });
}

§Feature flags

  • libudev – (enabled by default) Activates serialport crate libudev feature under-the-hood (required on Linux only for port listing).
  • serde – Enables serialize/deserialize capabilities for most entities.
  • mock – Provides mocked entities of all kinds (useful for tests mostly).

Modules§

animations
Create animations.
devices
Defines devices of various Input / Output kinds (led, servo, button, sensor, etc.) to be controlled.
errors
hardware
Defines pieces of hardware that can be remotely controlled through IO exchange messages.
io
Defines various protocols to control devices associated to boards.
utils
Various utilities and helper functions.

Macros§

pause
pause_sync

Attribute Macros§

runtime
Macro definition for Hermes-Five Runtime.