Skip to content

Commit aadeca5

Browse files
committed
Version 0.5.0
1 parent 8c118d2 commit aadeca5

File tree

7 files changed

+33
-18
lines changed

7 files changed

+33
-18
lines changed

app_rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "openvehiclediag"
3-
version = "0.1.0"
3+
version = "0.5.0"
44
authors = ["ashcon"]
55
edition = "2018"
66

app_rust/src/commapi/protocols/kwp2000.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,18 @@ pub enum DiagSession {
199199
ExtendedDiag = 0x92,
200200
}
201201

202+
impl ToString for DiagSession {
203+
fn to_string(&self) -> String {
204+
match &self {
205+
DiagSession::Normal => "Normal",
206+
DiagSession::ECUFlash => "Flash",
207+
DiagSession::StandBy => "Standby",
208+
DiagSession::ECUPassive => "Passive",
209+
DiagSession::ExtendedDiag => "Extended diagnostics"
210+
}.into()
211+
}
212+
}
213+
202214
impl DiagSession {
203215
pub (crate) fn send_tester_present(&self) -> bool {
204216
self != &DiagSession::Normal
@@ -418,14 +430,14 @@ impl ProtocolServer for KWP2000ECU {
418430
let mut timer = Instant::now();
419431
while should_run_t.load(Relaxed) {
420432
if let Ok(data) = channel_tx_receiver.try_recv() {
421-
let res = Self::run_command_isotp(comm_server.as_ref(), s_id, data.0, &data.1, data.2);
433+
let res = Self::run_command_iso_tp(comm_server.as_ref(), s_id, data.0, &data.1, data.2);
422434
if channel_rx_sender.send(res).is_err() {
423435
*last_error_t.write().unwrap() = Some(ProtocolError::CustomError("Sender channel died".into()));
424436
break
425437
}
426438
}
427439
if timer.elapsed().as_millis() >= 2000 && session_type_t.read().unwrap().send_tester_present() {
428-
if let Ok(res) = Self::run_command_isotp(comm_server.as_ref(), s_id, Service::TesterPresent.into(), &[0x01], true) {
440+
if let Ok(res) = Self::run_command_iso_tp(comm_server.as_ref(), s_id, Service::TesterPresent.into(), &[0x01], true) {
429441
println!("Tester present resp: {:02X?}", res);
430442
}
431443
timer = Instant::now();

app_rust/src/commapi/protocols/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl DiagServer {
142142

143143
impl Drop for DiagServer {
144144
fn drop(&mut self) {
145-
println!("Drop for diagserver called!");
145+
println!("Drop for Diag Server called!");
146146
self.kill_diag_server()
147147
}
148148
}
@@ -157,13 +157,12 @@ pub trait ProtocolServer: Sized {
157157
fn is_in_diag_session(&self) -> bool;
158158
fn get_last_error(&self) -> Option<String>;
159159

160-
fn run_command_isotp(server: &dyn ComServer, send_id: u32, cmd: u8, args: &[u8], receive_require: bool) -> std::result::Result<Vec<u8>, ProtocolError> {
160+
fn run_command_iso_tp(server: &dyn ComServer, send_id: u32, cmd: u8, args: &[u8], receive_require: bool) -> std::result::Result<Vec<u8>, ProtocolError> {
161161
let mut data = ISO15765Data {
162162
id: send_id,
163-
data: vec![],
163+
data: vec![cmd],
164164
pad_frame: false,
165165
};
166-
data.data.push(cmd);
167166
data.data.extend_from_slice(args);
168167
if !receive_require {
169168
server.send_iso15765_data(&[data], 0).map(|_| vec![]).map_err(ProtocolError::CommError)

app_rust/src/commapi/protocols/obd2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn read_write_payload_isotp(server: &mut Box<dyn ComServer>, payload: &OBDReques
1515

1616
let cfg = ISO15765Config {
1717
send_id: 0x07DF,
18-
recv_id: 0x7E8,
18+
recv_id: 0x07E8,
1919
block_size: 8, // Sensible decision
2020
sep_time: 20, // Sensible decision
2121
};

app_rust/src/windows/diag_session/json_session.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{cell::RefCell, cmp::min, collections::HashMap, sync::Arc, time::Instant};
1+
use std::{borrow::Borrow, cell::RefCell, cmp::min, collections::HashMap, sync::Arc, time::Instant};
22

33
use commapi::protocols;
44
use common::schema::{OvdECU, diag::service::{ParamDecodeError, Service}, variant::{ECUVariantDefinition, ECUVariantPattern}};
@@ -224,7 +224,7 @@ impl SessionTrait for JsonDiagSession {
224224

225225
fn subscription(&self) -> iced::Subscription<Self::msg> {
226226
if self.looping_service.is_some() {
227-
return time::every(std::time::Duration::from_millis(333)).map(JsonDiagSessionMsg::LoopRead);
227+
return time::every(std::time::Duration::from_millis(500)).map(JsonDiagSessionMsg::LoopRead);
228228
}
229229
Subscription::none()
230230
}
@@ -403,12 +403,12 @@ impl ServiceSelector {
403403
content_view = content_view.push(button_coloured(&mut self.execb, format!("{}{}", text, curr_service.inner.borrow().name).as_str(), ButtonType::Danger).on_press(SelectorMsg::ExecService))
404404
}
405405
if self.can_execute == self.view_selection[0] {
406-
// Show the loop button
407-
content_view = content_view.push(button_coloured(&mut self.l_btn, "Begin loop", ButtonType::Warning).on_press(SelectorMsg::BeginLoopService))
406+
// Show the graph button
407+
content_view = content_view.push(button_coloured(&mut self.l_btn, "Begin graphing", ButtonType::Info).on_press(SelectorMsg::BeginLoopService))
408408
}
409409
} else {
410410
// Stop the loop
411-
content_view = content_view.push(button_coloured(&mut self.l_btn, "Stop loop", ButtonType::Warning).on_press(SelectorMsg::StopLoopService))
411+
content_view = content_view.push(button_coloured(&mut self.l_btn, "Stop graphing", ButtonType::Info).on_press(SelectorMsg::StopLoopService))
412412
}
413413
}
414414

app_rust/src/windows/diag_session/kwp2000_session.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{borrow::BorrowMut, cell::RefCell, sync::{Arc, atomic::AtomicBool}, thread::JoinHandle, time::Instant};
22

3-
use iced::{Column, Container, Length, Row, Subscription, time};
3+
use iced::{Column, Container, Length, Row, Space, Subscription, time};
44
use log_view::{LogType, LogView};
55

66
use crate::{commapi::{comm_api::{ComServer, ISO15765Config}, protocols::{ProtocolServer, kwp2000::KWP2000ECU}}, themes::{ButtonType, TextType, TitleSize, button_outlined, text, title_text}, windows::{diag_manual::DiagManualMessage, window}};
@@ -72,6 +72,10 @@ impl SessionTrait for KWP2000DiagSession {
7272
if !in_session {
7373
ui = ui.push(button_outlined(&mut self.back_btn, "Back", ButtonType::Secondary).on_press(KWP2000DiagSessionMsg::Back))
7474
}
75+
ui = ui.push(Space::with_height(Length::Fill));
76+
if let Some(se) = &self.diag_server {
77+
ui = ui.push(Row::new().push(text(format!("Current session type: {}", se.get_session_type().to_string()).as_str(), TextType::Normal)));
78+
}
7579

7680
Row::new().spacing(8).padding(8)
7781
.push(ui.width(Length::FillPortion(1)))

app_rust/src/windows/window.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::windows::diag_home::{DiagHomeMessage};
99
use crate::windows::obd::{OBDMessage, OBDHome};
1010
use crate::themes::{toggle_theme, button_coloured, ButtonType, container, text, TextType};
1111

12-
use super::diag_home::{self, DiagHome};
12+
use super::diag_home::{DiagHome};
1313

1414

1515
// This can be modified by diagnostic sessions in order to disable going
@@ -289,9 +289,9 @@ impl MainWindow {
289289
impl Drop for MainWindow {
290290
fn drop(&mut self) {
291291
if let Some(mut s) = self.server.take() {
292-
s.close_iso15765_interface();
293-
s.close_can_interface();
294-
s.close_device();
292+
s.close_iso15765_interface().expect("Error closing ISO15765");
293+
s.close_can_interface().expect("Error closing can Interface");
294+
s.close_device().expect("Error closing device");
295295
}
296296
}
297297
}

0 commit comments

Comments
 (0)