Comments (8)
https://docs.rs/tokio-modbus/0.3.5/tokio_modbus/client/sync/rtu
There is a sync
module https://docs.rs/tokio-modbus/0.3.5/tokio_modbus/client/sync/index.html
from tokio-modbus.
https://docs.rs/tokio-modbus/0.3.5/tokio_modbus/client/sync/rtu
There is a
sync
module https://docs.rs/tokio-modbus/0.3.5/tokio_modbus/client/sync/index.html
The requested resource does not exist
from tokio-modbus.
Those both exist for me. There's also the direct example: https://github.com/slowtec/tokio-modbus/blob/master/examples/rtu-client.rs
from tokio-modbus.
Those both exist for me. There's also the direct example: https://github.com/slowtec/tokio-modbus/blob/master/examples/rtu-client.rs
its asnyc.
from tokio-modbus.
I'm wrote a example.
let mut settings = tokio_serial::SerialPortSettings::default();
settings.baud_rate = 115200;
println!("settings is '{:?}'", settings);
const SLAVE_1: Slave = Slave(0x01);
let result = sync::rtu::connect_slave("/dev/ttyUSB0", &settings, SLAVE_1);
let mut ctx = match result
{
Ok(ctx) => ctx,
Err(error) => {
println!("There was a problem connect to slave : {:?}", error);
return;
},
};
let time_ms = time::Duration::from_millis(500);
thread::sleep(time_ms);
println!("Write");
match ctx.write_single_register(0, 1)
{
Err(e) => {
println!("Error : '{:?}'", e);
}
Ok(f) => f,
};
thread::sleep(time_ms);
match ctx.write_single_register(1, 2)
{
Err(e) => {
println!("Error : '{:?}'", e);
}
Ok(f) => f,
};
println!("Write done");
let mut value = 1;
loop
{
println!("Write");
value = value + 1;
match ctx.write_single_register(0, value)
{
Err(e) => {
println!("Error : '{:?}'", e);
}
Ok(f) => f,
};
thread::sleep(time_ms);
println!("READ");
let buff = ctx.read_holding_registers(0,2).unwrap();
println!("Response is '{:?}'", buff);
}
I have a problem when not receive response.
How set timeout?
from tokio-modbus.
I was not ever able to get timeouts in sync working due to #19
So I currently use the async code and race it with a tokio timeout using either select2
in old tokio or select!
in new tokio (depending on if you're using 0.3.5 or master of tokio-modbus).
from tokio-modbus.
I was not ever able to get timeouts in sync working due to #19
So I currently use the async code and race it with a tokio timeout using eitherselect2
in old tokio orselect!
in new tokio (depending on if you're using 0.3.5 or master of tokio-modbus).
;(
I'm switching to https://github.com/zzeroo/libmodbus-rs
from tokio-modbus.
I'm switching to https://github.com/zzeroo/libmodbus-rs
Ok, so I'm closing this issue. Feel free to reopen it if there are questions left.
from tokio-modbus.
Related Issues (20)
- Flow control when using RS-485 HOT 2
- No timeout in the RTU client async implementation HOT 2
- Infinite retry loop with heavy CPU load HOT 5
- "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
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.