diff --git a/.sync-exclude.lst b/.sync-exclude.lst new file mode 100644 index 0000000..1e767df --- /dev/null +++ b/.sync-exclude.lst @@ -0,0 +1,5 @@ +target/* +target/ +output/* +output/ +Cargo.lock diff --git a/HARG_1022.txt b/HARG_1022.txt index 47d12fa..0e3141f 100644 --- a/HARG_1022.txt +++ b/HARG_1022.txt @@ -2,5 +2,4 @@ H2_A = 0.0 H2_B = 0.0 H2_C = 1.0 H2_D = 0.0 -HUMI_K = 1.0 -HUMI_B = 0.0 \ No newline at end of file +HUMI_K = 1.0 \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 3b54644..8a0577d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,7 +67,8 @@ fn main() { } else { println!("Нет доступных портов. Завершение работы . . ."); } - + let mut input=String::new(); + let _ = io::stdin().read_line(&mut input); // let options = eframe::NativeOptions { // // Hide the OS-specific "chrome" around the window: // decorated: true, @@ -112,8 +113,8 @@ fn mb_port_loop() -> Result { println!("Введите имя файла с коэффициентами:"); let mut path = String::new(); let _ = io::stdin().read_line(&mut path); - println!("{:#?}", path); - let path = path.trim_end(); + // println!("{:#?}", path); + let path = path.trim_matches(|c| c == '\"' || c == '\r' || c=='\n'); let file = OpenOptions::new().read(true).open(&path); let file = match file { Ok(file) => file, @@ -236,7 +237,7 @@ fn mb_port_loop() -> Result { .unwrap(); let response = mb_trancieve(&mut port_wf, &request)?; mb_req.parse_ok(&response).unwrap(); - thread::sleep(Duration::from_millis(20)); + thread::sleep(Duration::from_millis(200)); //Проверка ввода коэффициента mb_req @@ -267,7 +268,7 @@ fn mb_port_loop() -> Result { .unwrap(); let response = mb_trancieve(&mut port_wf, &request)?; mb_req.parse_ok(&response).unwrap(); - thread::sleep(Duration::from_millis(20)); + thread::sleep(Duration::from_millis(100)); //Проверка ввода коэффициента mb_req @@ -299,15 +300,17 @@ fn mb_port_loop() -> Result { mb_req.parse_ok(&response).unwrap(); let mut raw_str = Vec::new(); mb_req.parse_u16(&response, &mut raw_str).unwrap(); - + println!("Name\t|STAT\t|OUTPUT\t\t|INPUT"); for i in (1..12).step_by(2) { - let f = (raw_str[i] as u32) + (raw_str[i + 1] as u32) << 16; - let f = unsafe { mem::transmute::(f) }; - print!("{:#06X?}: ", coefs_cmds.cmd[i / 2]); - if coefs_cmds.coef[i / 2] != f { - println!("ERR"); + let int = (raw_str[i + 1] as u32) << 16 | (raw_str[i] as u32) ; + let f = unsafe { mem::transmute::(int) }; + let int2 = unsafe { mem::transmute::(coefs_cmds.coef[i / 2]) }; + // println!("{:#?}:\t",(coefs_cmds.coef[i / 2] - f).abs()); + print!("{:#06X?}:\t", coefs_cmds.cmd[i / 2]); + if (coefs_cmds.coef[i / 2] - f).abs() > (1.0/131072.0) { + println!("ERR:\t{:#010X?} |\t{:#010X?}",int,int2); } else { - println!("OK") + println!("OK"); } }