Skip to content

Whats the purpose of the sync rtu client? #70

@zzeroo

Description

@zzeroo

With the async rtu client under windows I had massive Permission denied issues (A separate issue follows).

Now I try to get the sync rtu part up and running and stumbled upon this one:

thread 'main' panicked at 'there is no reactor running, must be called from the context of Tokio runtime'

Here is my example

#[cfg(all(feature = "rtu", feature = "sync"))]
pub fn main() {
    use tokio_modbus::prelude::*;
    use tokio_serial::{Serial, SerialPortSettings};

    let tty_path = "/dev/ttyUSB0";
    let slave = Slave(247);
    let settings = SerialPortSettings::default();

    let mut ctx = sync::rtu::connect_slave(&tty_path, &settings, slave).unwrap();
    let buff = ctx.read_input_registers(0x1000, 7).unwrap();
    println!("Response is '{:?}'", buff);
}

#[cfg(not(all(feature = "rtu", feature = "sync")))]
pub fn main() {
    println!("features `rtu` and `sync` are required to run this example");
    std::process::exit(1);
}

Does the "sync" rtu part differ from the sync tcp one? The tcp example looks for me really sync without a runtime I mean.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions