mirror of
https://github.com/italicsjenga/mppt-modbus.git
synced 2024-12-23 16:51:30 +11:00
messages
This commit is contained in:
parent
3279207234
commit
40fec62a19
11
src/main.rs
11
src/main.rs
|
@ -91,16 +91,19 @@ fn main() {
|
||||||
let parity = 'N';
|
let parity = 'N';
|
||||||
let data_bit = 8;
|
let data_bit = 8;
|
||||||
let stop_bit = 2;
|
let stop_bit = 2;
|
||||||
|
println!("Connecting to device on {}", args.serial_port);
|
||||||
let mut modbus = Modbus::new_rtu(&args.serial_port, baud, parity, data_bit, stop_bit)
|
let mut modbus = Modbus::new_rtu(&args.serial_port, baud, parity, data_bit, stop_bit)
|
||||||
.expect("could not create modbus device");
|
.expect("Could not create modbus device");
|
||||||
modbus
|
modbus
|
||||||
.set_slave(DEVICE_ID)
|
.set_slave(DEVICE_ID)
|
||||||
.expect("could not set client device");
|
.expect("Could not set client device");
|
||||||
modbus.connect().expect("could not connect");
|
modbus
|
||||||
|
.connect()
|
||||||
|
.expect("Could not connect to client device");
|
||||||
let mut data: [u16; 5] = [0; 5];
|
let mut data: [u16; 5] = [0; 5];
|
||||||
modbus
|
modbus
|
||||||
.read_registers(0x0000, 5, &mut data)
|
.read_registers(0x0000, 5, &mut data)
|
||||||
.expect("couldnt read registers");
|
.expect("Could not read registers");
|
||||||
println!("voltage scaling (whole term): {}", get_floating(data[0]));
|
println!("voltage scaling (whole term): {}", get_floating(data[0]));
|
||||||
println!(
|
println!(
|
||||||
"voltage scaling (fractional term): {}",
|
"voltage scaling (fractional term): {}",
|
||||||
|
|
Loading…
Reference in a new issue