make modem init a file

This commit is contained in:
Daniella / Tove 2023-12-28 01:16:24 +01:00
parent 43d208a39f
commit 9d712ddd10
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
2 changed files with 6 additions and 2 deletions

View file

@ -1,6 +1,7 @@
use core::panic;
use std::{
collections::HashMap,
fs,
io::{Read, Write},
net::TcpStream,
thread,
@ -41,7 +42,10 @@ fn connect(params: &ClientParams) -> Connection {
.unwrap();
if let Some(modem_init) = params.modem_init {
serial.set_timeout(Duration::from_millis(200)).unwrap();
for line in modem_init.lines() {
for line in fs::read_to_string(modem_init)
.expect("invalid modem init file")
.lines()
{
let line = line
.replace("$IP", &params.server_ip.to_string())
.replace("$PORT", &params.server_port.to_string());

View file

@ -31,5 +31,5 @@ fn main() {
}
eprintln!("Usage: \n\
\x20 revpfw3 server <port> <key> [<poll delay>]\n\
\x20 revpfw3 client <server ip> <server port> <destination ip> <destination port> <key> [<poll delay> [<modem port> <modem baud> <modem init>]]");
\x20 revpfw3 client <server ip> <server port> <destination ip> <destination port> <key> [<poll delay> [<modem port> <modem baud> <modem init file>]]");
}