Comments (3)
any progress / plans for this?
it made me ditch the sync client and write this async abomination instead (my first time using futures, too)
let mut rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
let mut ctx = tokio::time::timeout(Duration::from_secs(3),
tokio_modbus::client::tcp::connect_slave(socket_addr, Slave(12)))
.await.unwrap().unwrap();
// more stuff
});
from tokio-modbus.
@jvelo Sorry for the late reply.
The TCP connection currently is managed by the deprecated tokio-proto
crate that no longer is maintained. Unfortunately there is no drop-in replacement for that.
I already ask for a possible replacement more than a year ago (tokio-rs/tokio-proto#202 (comment)) but there is not really a progress on that :(
This is why we're going to remove the dependency entirely. The corresponding issue is discussed in #18
Probably we first will release a v0.3.x
(#10 ) and will work on a tokio-proto
replacement in a v0.4.x
release.
Until then you might use a custom wrapper with a timeout feature.
from tokio-modbus.
any progress / plans for this?
it made me ditch the sync client and write this async abomination instead (my first time using futures, too)
let mut rt = tokio::runtime::Runtime::new().unwrap(); rt.block_on(async { let mut ctx = tokio::time::timeout(Duration::from_secs(3), tokio_modbus::client::tcp::connect_slave(socket_addr, Slave(12))) .await.unwrap().unwrap(); // more stuff });
This saved me. Ugly but works
from tokio-modbus.
Related Issues (20)
- "Device or resource busy" in RTU server example HOT 3
- Generalize impl around `Service` usage HOT 5
- Tokio module 'runtime' is private HOT 12
- Asyncronous responses / Multiplexing HOT 2
- How to convert tokio_modbus::Request to bytes? HOT 5
- TCP server example - shared data hashmap HOT 5
- TCP Sync Client HOT 6
- 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
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.