Skip to content

Commit 788a001

Browse files
committed
fix issues for windows and prepare for release v0.2.2
1 parent da76edb commit 788a001

File tree

5 files changed

+31
-10
lines changed

5 files changed

+31
-10
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "can-viewer"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
edition = "2021"
55
description = "view real-time CAN packages"
66

@@ -27,7 +27,7 @@ winresource = "0.1.17"
2727
[package.metadata.bundle]
2828
name = "can-viewer"
2929
icon = ["ui/images/can_viewer_32px.png", "ui/images/can_viewer_128px.png", "ui/images/can_viewer_256px.png"]
30-
version = "0.2.1"
30+
version = "0.2.2"
3131
copyright = "Copyright (c) Tu Nguyen 2024. All rights reserved."
3232
category = "Developer Tool"
3333
short_description = "view real-time CAN packages"
@@ -37,5 +37,5 @@ can-view can records real-time can packages and parse data with DBC input.
3737
"""
3838

3939
[package.metadata.winresource]
40-
OriginalFilename = "can-viewer_0.2.1.exe"
40+
OriginalFilename = "can-viewer_0.2.2.exe"
4141
LegalCopyright = "Copyright © 2024"

src/event_handler/init.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ impl<'a> Init<'a> {
5353
let mut interface_names = Vec::default();
5454
let mut interface_index = Vec::default();
5555
let mut count = 0;
56-
for channel in channels {
56+
for channel in interface {
5757
let interface_name = SharedString::from(format!(
5858
"{}(0x{:02X})",
5959
channel.device_name(),
6060
channel.channel_information.device_id
6161
));
62-
interface_names.push(socket_name);
62+
interface_names.push(interface_name);
6363
interface_index
6464
.push(channel.channel_information.channel_handle as i32);
6565
count += 1;
@@ -84,7 +84,7 @@ impl<'a> Init<'a> {
8484
Err(e) => {
8585
let _ = self.ui_handle.upgrade_in_event_loop(move |ui| {
8686
ui.set_init_string(SharedString::from(format!(
87-
"Can't get device list: {}",
87+
"Can't get device list: {:?}",
8888
e
8989
)));
9090
let socket_info = socket_info {

src/event_handler/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,30 @@ pub use can_handler::CanHandler;
77
pub use dbc_file::DBCFile;
88
pub use init::Init;
99
pub use packet_filter::PacketFilter;
10+
#[cfg(target_os = "windows")]
11+
use pcan_basic::socket::Baudrate;
1012
use slint::Color;
1113

1214
const ODD_COLOR: Color = Color::from_rgb_u8(0x18, 0x1c, 0x27);
1315
const EVEN_COLOR: Color = Color::from_rgb_u8(0x13, 0x16, 0x1f);
16+
17+
#[cfg(target_os = "windows")]
18+
pub fn p_can_bitrate(bitrate: &str) -> Option<Baudrate> {
19+
match bitrate {
20+
"1 Mbit/s" => Some(Baudrate::Baud1M),
21+
"800 kbit/s" => Some(Baudrate::Baud800K),
22+
"500 kbit/s" => Some(Baudrate::Baud500K),
23+
"250 kbit/s" => Some(Baudrate::Baud250K),
24+
"125 kbit/s" => Some(Baudrate::Baud125K),
25+
"100 kbit/s" => Some(Baudrate::Baud100K),
26+
"95.238 kbit/s" => Some(Baudrate::Baud95K),
27+
"83.333 kbit/s" => Some(Baudrate::Baud83),
28+
"50 kbit/s" => Some(Baudrate::Baud50K),
29+
"47.619 kbit/s" => Some(Baudrate::Baud47K),
30+
"33.333 kbit/s" => Some(Baudrate::Baud33K),
31+
"20 kbit/s" => Some(Baudrate::Baud20K),
32+
"10 kbit/s" => Some(Baudrate::Baud10K),
33+
"5 kbit/s" => Some(Baudrate::Baud5K),
34+
_ => None,
35+
}
36+
}

src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ mod event_handler;
66
use can_dbc::DBC;
77
use event_handler::{CanHandler, DBCFile, Init, PacketFilter};
88
#[cfg(target_os = "windows")]
9-
use pcan_basic::{
10-
bus::UsbBus, hw::attached_channels as available_interfaces, socket::usb::UsbCanSocket,
11-
};
9+
use pcan_basic::{bus::UsbBus, socket::usb::UsbCanSocket};
1210
#[cfg(target_os = "linux")]
1311
use privilege_rs::privilege_request;
1412
#[cfg(target_os = "windows")]

ui/app.slint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export component AppWindow inherits Window {
2626
callback open_dbc_file();
2727
callback filter_id(CanData, bool);
2828
callback start(string, int, string);
29-
title: @tr("CAN VIEWER (version 0.2.0)");
29+
title: @tr("CAN VIEWER (version 0.2.2)");
3030
icon: @image-url("images/can_viewer_128px.png");
3131
background: #1a1f2b;
3232
default-font-family: "Noto Sans";

0 commit comments

Comments
 (0)