mirror of
https://github.com/italicsjenga/mppt-modbus.git
synced 2024-12-23 16:51:30 +11:00
packaging etc
This commit is contained in:
parent
0c0178b316
commit
c594cf1e8b
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -382,7 +382,7 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "modbus-test"
|
name = "mppt-control"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "modbus-test"
|
name = "mppt-control"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
1
install.sh
Executable file
1
install.sh
Executable file
|
@ -0,0 +1 @@
|
||||||
|
git pull && cargo install --path .
|
10
src/main.rs
10
src/main.rs
|
@ -1,3 +1,5 @@
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use libmodbus_rs::{Modbus, ModbusClient, ModbusRTU};
|
use libmodbus_rs::{Modbus, ModbusClient, ModbusRTU};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -125,6 +127,7 @@ struct Info {
|
||||||
v_scale: f32,
|
v_scale: f32,
|
||||||
i_scale: f32,
|
i_scale: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Info {
|
impl Info {
|
||||||
pub fn from(data: &[u16]) -> Self {
|
pub fn from(data: &[u16]) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -155,6 +158,13 @@ fn main() {
|
||||||
let parity = 'N';
|
let parity = 'N';
|
||||||
let data_bit = 8;
|
let data_bit = 8;
|
||||||
let stop_bit = 2;
|
let stop_bit = 2;
|
||||||
|
if !Path::new(&args.serial_port).exists() {
|
||||||
|
println!(
|
||||||
|
"Serial port {} does not exist\nTry \"mppt-control --help\" for usage instructions",
|
||||||
|
args.serial_port
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
println!("Connecting to device on {}", args.serial_port);
|
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");
|
||||||
|
|
Loading…
Reference in a new issue