Skip to main content

Module io

Module io 

Source
Available on crate feature std only.
Expand description

A blocking frame reader over std::io::Read: a serial port, a USB infrared head, a TCP socket or a capture file.

use sml_kit::{Obis, io::FrameReader};

let port = std::fs::File::open("/dev/ttyUSB0")?; // 9600 8N1, configured beforehand
for frame in FrameReader::new(port) {
    let Ok(frame) = frame else { continue }; // a damaged frame, or a read timeout
    if let Ok(list) = sml_kit::readout(&frame) {
        println!("A+ = {:?}", list.quantity(Obis::ENERGY_IMPORT));
    }
}

Only available with the std feature. The core decoder underneath is the same sans-I/O Decoder.

Structs§

FrameReader
An iterator of verified transport payloads read from R.

Enums§

ReadError
What can go wrong while reading frames.

Constants§

DEFAULT_CAPACITY
The largest frame FrameReader::new accepts: far more than any meter telegram.