Comments (6)
You need to enable the required features manually: rust-lang/cargo#4663
cargo run --example tcp-client-sync --features tcp-sync
from tokio-modbus.
I did that, and it returns error: none of the selected packages contains these features: tcp-sync
To confirm, I have [dependencies] tokio-modbus = "*"
in the toml file
from tokio-modbus.
I tested it on the main
branch and it works.
from tokio-modbus.
I don't know anything about your private project. But it looks like you forgot to add the feature to the dependency.
from tokio-modbus.
Thanks Uwe. That was my bad. I got it to build ok. I changed the example like this
fn main() {
use tokio_modbus::prelude::*;
let socket_addr = "10.2.16.171:502".parse().unwrap();
let mut ctx = sync::tcp::connect(socket_addr).unwrap();
let buff = ctx.read_input_registers(3, 1).unwrap();
println!("Response is '{buff:?}'");
}
And it returns
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `../tokio-modbus/target/debug/examples/tcp-client-sync`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: ExceptionResponse { function: 4, exception: IllegalDataAddress } }', examples/tcp-client-sync.rs:11:47
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Yet mbpoll is able to see the data:
mbpoll -m tcp -a 1 -t 4 -r 3 -c 1 -1 10.2.16.171
......
Protocol configuration: Modbus TCP
Slave configuration...: address = [1]
start reference = 3, count = 1
Communication.........: 10.2.16.171, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table
-- Polling slave 1...
[3]: 2
Any ideas?
from tokio-modbus.
Check the tokio-modbus docs about 0/1-based addressing.
from tokio-modbus.
Related Issues (20)
- How to convert tokio_modbus::Request to bytes? HOT 5
- TCP server example - shared data hashmap HOT 5
- 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
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.