Crates.io | tinkerforge |
lib.rs | tinkerforge |
version | 2.0.21 |
source | src |
created_at | 2018-11-08 13:05:23.739248 |
updated_at | 2024-02-27 17:29:37.747882 |
description | Rust API bindings for https://www.tinkerforge.com Bricks and Bricklets. |
homepage | https://tinkerforge.com |
repository | https://github.com/Tinkerforge/generators |
max_upload_size | |
id | 95475 |
size | 5,018,328 |
This crate provides API bindings for Tinkerforge bricks and bricklets.
Add tinkerforge = "2.0"
to the [dependencies]
of your project's Cargo.toml.
First, import the IP connection and any devices you want to use:
use tinkerforge::{ip_connection::*, temperature_bricklet::*}
You can than create instances like this:
let ipcon = IpConnection::new();
let t = TemperatureBricklet::new("UID", &ipcon);
where "UID"
is the unique identifier of your brick or bricklet. Once the IP connection is established using:
ipcon.connect((HOST, PORT)).recv()??;
you can use the device's API, for example:
let temperature = t.get_temperature().recv()? as f32 / 100.0;
Further examples can be found here.
The bindings require the rust compiler in version 1.41 or higher.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be triple licensed as above, without any additional terms or conditions.