Protocols & transports
All protocols within the application (see Protocol Layer) must implement IoProtocol
trait. This page lists the protocols currently available.
Methods of a Protocol | Description | |
---|---|---|
get_io | Returns the IoData associated with the protocol. | doc |
get_protocol_name | Returns the procol name (RemoteIo, RaspiIo, etc.) | doc |
open | Opens the communication using the underlying protocol. | doc |
close | Gracefully shuts down the communication. | doc |
is_connected | Checks if the communication is opened using the underlying protocol. | doc |
set_pin_mode | Sets the mode of the specified pin . | doc |
digital_write | Writes level to the digital pin . | doc |
analog_write | Writes level to the analog pin . | doc |
report_analog | Sets the analog reporting state of the specified analog pin . | doc |
report_digital | Sets the digital reporting state of the specified digital pin . | doc |
sampling_interval | Set the sampling interval (in ms). | doc |
servo_config | Configures the servo pwm range . | doc |
i2c_config | Sets a delay in microseconds between I2C devices write/read operations. | doc |
i2c_read | Reads size bytes from I2C device at the specified address . | doc |
i2c_write | Writes data to the I2C device at the specified address . | doc |
RemoteIo
RemoteIo
is the default protocol for a board created with no special configuration.
let board = Board::run();
let board = Board::default ().open();
Its purpose is to control a board remotely connected to the backend that run the software. The remote connection is established via the transport layer which RemoteIo
must use. All transports within the application (see Transport Layer) must implement IoTransport
trait.
Serial
The Serial
transport layer lets you control a remote board connected via a serial cable to your backend. That is the simplest solution you could image: an Arduino board for instance, cable-connected to your computer.
let board = Board::from(Serial::default ()); // RemoteIo + serial with default port.
let board = Board::new(RemoteIo::new("COM3")); // custom port
let board = Board::new(RemoteIo::from(Serial::new("COM3"))); // custom transport
Ethernet (coming soon)
(coming soon)
RaspiIo (coming soon)
(coming soon)
The purpose of RaspiIo is to control the input output pins of a RaspberryPi collocated to where your software would run. Meaning in that case: everything from your Backend Layer to your Hardware Layer is squashed into a single RaspberryPi
let board = Board::new(RaspiIo::default ());