#hal #arm #cortex-m #stm32l0x1

no-std elatec-twn4-simple

embedded-hal implementation of an Elatec TWN4 Simple Protocol client

1 unstable release

Uses old Rust 2015

0.1.0 Jun 26, 2018

#170 in #hal

0BSD license

23KB
469 lines

elatec-twn4-simple ####################

This is an implementation of the Simple Protocol for the Elatec TWN4 family of devices, based on embedded-hal.

It is an incomplete implementation, and contains only what the author has needed. Contributions are welcomed!

Example

Because elatec-twn4-simple uses embedded-hal, we can use serial-embedded-hal to test functionality on a desktop computer the same way we would on an embedded device.

extern crate elatec_multitec_nano_simple as reader;
extern crate embedded_hal;
extern crate serial_embedded_hal as serial;

use std::time::Duration;

fn main() {
    env_logger::init();

    let settings = serial::PortSettings {
        baud_rate: serial::BaudRate::Baud9600,
        char_size: serial::CharSize::Bits8,
        parity: serial::Parity::ParityNone,
        stop_bits: serial::StopBits::Stop1,
        flow_control: serial::FlowControl::FlowNone,
    };
    let (tx, rx) = serial::Serial::new("/dev/tty.usbmodem142331", &settings).unwrap().split();

    let mut reader = reader::new(rx, tx);

    let mut ver_buf = [0u8; 0xFF];

    let v_len = reader.get_version_string(&mut ver_buf).unwrap();

    println!(
        "ver: {} \"{}\"",
        v_len,
        std::str::from_utf8(&ver_buf[..v_len as usize]).unwrap()
    );
}

Dependencies

~280KB