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]]
|
||||
name = "modbus-test"
|
||||
name = "mppt-control"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "modbus-test"
|
||||
name = "mppt-control"
|
||||
version = "0.1.0"
|
||||
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 libmodbus_rs::{Modbus, ModbusClient, ModbusRTU};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -125,6 +127,7 @@ struct Info {
|
|||
v_scale: f32,
|
||||
i_scale: f32,
|
||||
}
|
||||
|
||||
impl Info {
|
||||
pub fn from(data: &[u16]) -> Self {
|
||||
Self {
|
||||
|
@ -155,6 +158,13 @@ fn main() {
|
|||
let parity = 'N';
|
||||
let data_bit = 8;
|
||||
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);
|
||||
let mut modbus = Modbus::new_rtu(&args.serial_port, baud, parity, data_bit, stop_bit)
|
||||
.expect("Could not create modbus device");
|
||||
|
|
Loading…
Reference in a new issue