fin 2
This commit is contained in:
parent
05b4f35d52
commit
34a23ea200
@ -1,15 +1,14 @@
|
|||||||
use crate::curl::startup;
|
|
||||||
|
|
||||||
mod json;
|
mod json;
|
||||||
mod curl;
|
mod curl;
|
||||||
mod serial;
|
mod serial;
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let data_file = std::path::Path::new("data.json");
|
let data_file = std::path::Path::new("data.json");
|
||||||
let data = json::get_json(data_file);
|
let data = json::get_json(data_file);
|
||||||
let req;
|
let req;
|
||||||
let dt;
|
let dt;
|
||||||
(req, dt) = startup(&data);
|
(req, dt) = curl::startup(&data);
|
||||||
serial::read_messages(req, &dt);
|
serial::read_messages(req, &dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,11 +23,15 @@ pub fn read_messages(mut request: curl::easy::Easy, data: &str) {
|
|||||||
loop {
|
loop {
|
||||||
match connection.read(serial_buf.as_mut_slice()) {
|
match connection.read(serial_buf.as_mut_slice()) {
|
||||||
Ok(t) => {
|
Ok(t) => {
|
||||||
|
if t < 1 { continue; }
|
||||||
let output = String::from_utf8_lossy(&serial_buf[..t]);
|
let output = String::from_utf8_lossy(&serial_buf[..t]);
|
||||||
if output.contains("1") {
|
if output.contains("1") {
|
||||||
// send curl request
|
// send curl request
|
||||||
let res = crate::curl::request(&mut request, &data);
|
let res = crate::curl::request(&mut request, &data);
|
||||||
println!("Response code: {}", res.unwrap());
|
match res {
|
||||||
|
Some(t) => println!("Response code: {t}"),
|
||||||
|
None => eprintln!("[ERROR] Something went wrong with the CURL request"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {}
|
Err(_) => {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user