packaging etc

This commit is contained in:
Alex Janka 2022-09-05 09:30:24 +10:00
parent 0c0178b316
commit c594cf1e8b
4 changed files with 13 additions and 2 deletions

2
Cargo.lock generated
View file

@ -382,7 +382,7 @@ dependencies = [
]
[[package]]
name = "modbus-test"
name = "mppt-control"
version = "0.1.0"
dependencies = [
"bincode",

View file

@ -1,5 +1,5 @@
[package]
name = "modbus-test"
name = "mppt-control"
version = "0.1.0"
edition = "2021"

1
install.sh Executable file
View file

@ -0,0 +1 @@
git pull && cargo install --path .

View file

@ -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");