tokio-resol-vbus 0.1.0

A Rust library for processing RESOL VBus data asynchronusly.

A library to wrap the resol-vbus crate to be used asynchronously in conjunction with the tokio crate. Travis Build Status

Documentation Repository


Recorder of live VBus data into a persistent file format

use std::fs::File;

use resol_vbus::{DataSet, RecordingWriter};
use tokio::{net::TcpStream, prelude::*};

use tokio_resol_vbus::{Error, LiveDataStream, TcpClientHandshake};

fn main() {
    // Create an recording file and hand it to a `RecordingWriter`
    let file = File::create("test.vbus").expect("Unable to create output file");
    let mut rw = RecordingWriter::new(file);

    // Parse the address of the DL2 to connect to
    let addr = ""
        .expect("Unable to parse address");

    // Connect to the DL2
    let handler = TcpStream::connect(&addr)

        // Start the handshake

        // Authenticate using a password
        .and_then(|hs| hs.send_pass_command("vbus"))

        // Switch to VBus data mode
        .and_then(|hs| hs.send_data_command())

        .and_then(|socket| {
            // Wrap the socket in a VBus `LiveDataStream`
            let (reader, writer) = socket.split();
            let stream = LiveDataStream::new(reader, writer, 0, 0x0020);

            // Read VBus `Data` values from the `LiveDataStream`
            stream.for_each(move |data| {
                println!("{}", data.id_string());

                // Add `Data` value into `DataSet` to be stored
                let mut data_set = DataSet::new();
                data_set.timestamp = data.as_ref().timestamp;

                // Write the `DataSet` into the `RecordingWriter` for permanent storage
                    .expect("Unable to write data set");


        .map_err(|err| {
            eprintln!("{}", err);

    // Start the tokio runtime