Comments (12)
This appears to be caused by this https://github.com/tokio-rs/tokio/blame/master/tokio/src/lib.rs#L536-L541
from tokio-modbus.
... so it's not related to tokio-modbus
, right?
from tokio-modbus.
This is related to tokio-modbus
, the error comes from it trying to access the runtime
tokio module without the cfg_rt!
(I don't know what that macro expands to, likely a cfg feature flag?)
from tokio-modbus.
hm... I tried to compile some examples and could not reproduce this error. Could you provide some more info to reproduce it?
from tokio-modbus.
Cargo.toml
[package]
name = "test"
version = "0.0.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tokio-modbus = { version = "0.8.0", default-features = false, features = ["rtu-sync"] }
tokio-serial = "5.4.4"
src/main.rs
examples/rtu-client-sync.rs
// SPDX-FileCopyrightText: Copyright (c) 2017-2023 slowtec GmbH <[email protected]>
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Synchronous RTU client example
fn main() -> Result<(), Box<dyn std::error::Error>> {
use tokio_modbus::prelude::*;
let tty_path = "/dev/ttyUSB0";
let slave = Slave(0x17);
let builder = tokio_serial::new(tty_path, 19200);
let mut ctx = sync::rtu::connect_slave(&builder, slave)?;
println!("Reading a sensor value");
let rsp = ctx.read_holding_registers(0x082B, 2)?;
println!("Sensor value is: {rsp:?}");
Ok(())
}
from tokio-modbus.
It appears to be because of default-features = false
, it's been a while since I touched my project and I just updated it, but this comment implies it's still an intended use-case, probably one of the optional dependencies from a different feature is explicitly required.
from tokio-modbus.
I'm so sorry, I'm still not able to produce the error, even if I disable the default features 🤔
This is what works fine on my machine:
cargo check --no-default-features --features rtu-sync --example rtu-client-sync
from tokio-modbus.
Yes that command works if I clone tokio-modbus and run it within, this only happens in a new project with tokio-modbus as a dependency
from tokio-modbus.
Here's my test project if you like, it's just the above two files Test.zip
$ cargo build
from tokio-modbus.
I see...you're right!
from tokio-modbus.
Could you check if #192 solves the problem?
from tokio-modbus.
That does fix it 👍
from tokio-modbus.
Related Issues (20)
- TCP server example - shared data hashmap HOT 5
- TCP Sync Client HOT 8
- write_multiple_registers taking array as a param HOT 3
- Can not disconnect slave, need help HOT 3
- Although disconnect the context, the SerialStream reopen error HOT 1
- Patterns/best practice for reconnect-after-failure? HOT 1
- How to turn 'tokio_serial::SerialStream' into global static to save it for reuse
- is_connected()? HOT 1
- Modbus RTU - Serial Direction Pin HOT 6
- Dev Dependencies: Upgrade rustls-pemfile and tokio-rustls HOT 4
- Return Modbus exception codes for client and server.
- Use `async-trait` in `Service` trait ? HOT 10
- tokio-modbus 0.12 entering unreachable code in any response error HOT 7
- Dev Dependencies: Upgrade rustls
- How to get hexadecimal modbus rtu message data HOT 2
- Panic on unreachable code on disconnect HOT 3
- SECS/GEM SEMI? HOT 2
- Cant ignore Modbus RTU Request HOT 3
- Is it possible change trait Service to be a async trait? HOT 9
- rtu-server-address hangs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tokio-modbus.