Skip to content

Commit 8e8a9de

Browse files
authored
Merge pull request #26 from rnd-ash/comm_api_rework
Version 1.0.5
2 parents 64a2b6f + a594bc9 commit 8e8a9de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2656
-1179
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The idea is to make diagnosing and exploring your cars diagnostics functions pos
77
This is for my University FYP for my degree at the University of Reading
88

99
### Latest release
10-
[Version 1.0.0 (21/04/21)](https://github.com/rnd-ash/OpenVehicleDiag/releases/tag/v1.0.0)
10+
[Version 1.0.5 (15/05/21)](https://github.com/rnd-ash/OpenVehicleDiag/releases/tag/v1.0.0)
1111

1212
## Youtube video playlist
1313
Videos showing OpenVehicleDiag in use and its development progress can be found [here](https://youtube.com/playlist?list=PLxrw-4Vt7xtty50LmMoLXN2iKiUknbMng)

app_rust/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[package]
22
name = "openvehiclediag"
3-
version = "1.0.0"
3+
version = "1.0.5"
44
description = "pen Vehicle Diagnostics (OVD) is a Rust-based open source vehicle ECU diagnostic platform."
55
edition = "2018"
6+
67
[package.metadata.bundle]
78
version = "0.6.0"
89
authors = ["ashcon"]
@@ -33,6 +34,8 @@ hex-serde = "0.1.0"
3334
chrono = "0.4.19"
3435
hex = "0.4.2"
3536
image = "0.23.12"
37+
dialog = "0.3.0"
38+
backtrace = "0.3.59"
3639

3740
[target.'cfg(windows)'.dependencies]
3841
winreg = "0.8"

app_rust/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Open vehicle diagnostics app
22

3-
4-
53
## Features (Current)
64
* CAN Tracer
75
* OBD Toolbox

app_rust/src/cli_tests/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub mod draw_routine {
4444
block_size: 8,
4545
sep_time: 20,
4646
use_ext_isotp: false,
47-
use_ext_can: false
47+
use_ext_can: false,
4848
},
4949
None,
5050
)

app_rust/src/commapi/comm_api.rs

Lines changed: 11 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ pub struct ISO15765Config {
9898
unsafe impl Send for ISO15765Config {}
9999
unsafe impl Sync for ISO15765Config {}
100100

101-
#[derive(Debug, Copy, Clone)]
101+
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
102102
pub enum FilterType {
103-
Pass,
104-
Block,
103+
Pass { id: u32, mask: u32 },
104+
Block { id: u32, mask: u32 },
105+
IsoTP { id: u32, mask: u32, fc: u32 },
105106
}
106107

107108
#[derive(Debug, Clone)]
@@ -224,8 +225,11 @@ pub trait ComServer: Send + Sync + Debug {
224225
/// ## Returns
225226
/// The number of CAN Frames successfully written to the vehicle, if Timeout is 0, this
226227
/// number will always be equal to the number of frames that were provided.
227-
fn send_can_packets(&mut self, data: &[CanFrame], timeout_ms: u32)
228-
-> Result<usize, ComServerError>;
228+
fn send_can_packets(
229+
&mut self,
230+
data: &[CanFrame],
231+
timeout_ms: u32,
232+
) -> Result<usize, ComServerError>;
229233

230234
/// Returns a boolean indicating if there is at least 1 channel communicating with the car
231235
fn is_connected(&self) -> bool;
@@ -326,27 +330,14 @@ pub trait ComServer: Send + Sync + Debug {
326330
///
327331
/// ## Returns
328332
/// The filter ID provided by the adapter. Use this when destroying the filter
329-
fn add_can_filter(&mut self, filter: FilterType, id: u32, mask: u32)
330-
-> Result<u32, ComServerError>;
333+
fn add_can_filter(&mut self, f: FilterType) -> Result<u32, ComServerError>;
331334

332335
/// Tells the adapter to remove an active filter on an open CAN channel
333336
/// # Params
334337
/// * filter_idx - Filter ID to remove, this should be the value given by [`add_can_filter`](fn@add_can_filter)
335338
fn rem_can_filter(&mut self, filter_idx: u32) -> Result<(), ComServerError>;
336339

337-
fn add_iso15765_filter(&mut self, id: u32, mask: u32, fc_id: u32) -> Result<u32, ComServerError>;
338-
339-
fn configure_iso15765(&mut self, cfg: &ISO15765Config) -> Result<u32, ComServerError> {
340-
self.add_iso15765_filter(cfg.recv_id, 0xFFFF, cfg.send_id)
341-
.and_then(|idx| {
342-
self.set_iso15765_params(cfg.sep_time, cfg.block_size)
343-
.map(|_| idx)
344-
.map_err(|e| match self.rem_iso15765_filter(idx) {
345-
Ok(_) => e,
346-
Err(e1) => e1,
347-
})
348-
})
349-
}
340+
fn add_iso15765_filter(&mut self, f: FilterType) -> Result<u32, ComServerError>;
350341

351342
/// Tells the adapter to remove an active filter on an open ISO15765 channel
352343
/// # Params
@@ -369,33 +360,6 @@ pub trait ComServer: Send + Sync + Debug {
369360
block_size: u32,
370361
) -> Result<(), ComServerError>;
371362

372-
/// Sends an ISOTP payload and attempts to read the ECUs response
373-
/// IMPORTANT - This function assumes the ISO15765 interface is ALREADY open
374-
fn send_receive_iso15765(
375-
&self,
376-
p: ISO15765Data,
377-
max_timeout_ms: u128,
378-
max_resp: usize,
379-
) -> Result<Vec<ISO15765Data>, ComServerError> {
380-
self.clear_iso15765_rx_buffer()?; // Clear the receive buffer
381-
self.send_iso15765_data(&[p], 0)?; // Send data
382-
let mut timeout = max_timeout_ms;
383-
let mut payloads: Vec<ISO15765Data> = Vec::new();
384-
let start = Instant::now();
385-
while start.elapsed().as_millis() < timeout {
386-
if let Ok(d) = self.read_iso15765_packets(0, 10) {
387-
for msg in d {
388-
payloads.push(msg);
389-
if max_resp != 0 && payloads.len() >= max_resp {
390-
timeout = 0; // Return now!
391-
}
392-
}
393-
}
394-
std::thread::sleep(std::time::Duration::from_millis(1));
395-
}
396-
Ok(payloads)
397-
}
398-
399363
/// Tells the adapter to clear any data in its Rx buffer
400364
/// that is from CAN protocol
401365
fn clear_can_rx_buffer(&self) -> Result<(), ComServerError>;

0 commit comments

Comments
 (0)