Skip to content

Commit

Permalink
fix issues for windows and prepare for release v0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TuEmb committed Sep 16, 2024
1 parent da76edb commit 788a001
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "can-viewer"
version = "0.2.1"
version = "0.2.2"
edition = "2021"
description = "view real-time CAN packages"

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

[package.metadata.winresource]
OriginalFilename = "can-viewer_0.2.1.exe"
OriginalFilename = "can-viewer_0.2.2.exe"
LegalCopyright = "Copyright © 2024"
6 changes: 3 additions & 3 deletions src/event_handler/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ impl<'a> Init<'a> {
let mut interface_names = Vec::default();
let mut interface_index = Vec::default();
let mut count = 0;
for channel in channels {
for channel in interface {
let interface_name = SharedString::from(format!(
"{}(0x{:02X})",
channel.device_name(),
channel.channel_information.device_id
));
interface_names.push(socket_name);
interface_names.push(interface_name);
interface_index
.push(channel.channel_information.channel_handle as i32);
count += 1;
Expand All @@ -84,7 +84,7 @@ impl<'a> Init<'a> {
Err(e) => {
let _ = self.ui_handle.upgrade_in_event_loop(move |ui| {
ui.set_init_string(SharedString::from(format!(
"Can't get device list: {}",
"Can't get device list: {:?}",
e
)));
let socket_info = socket_info {
Expand Down
23 changes: 23 additions & 0 deletions src/event_handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,30 @@ pub use can_handler::CanHandler;
pub use dbc_file::DBCFile;
pub use init::Init;
pub use packet_filter::PacketFilter;
#[cfg(target_os = "windows")]
use pcan_basic::socket::Baudrate;
use slint::Color;

const ODD_COLOR: Color = Color::from_rgb_u8(0x18, 0x1c, 0x27);
const EVEN_COLOR: Color = Color::from_rgb_u8(0x13, 0x16, 0x1f);

#[cfg(target_os = "windows")]
pub fn p_can_bitrate(bitrate: &str) -> Option<Baudrate> {
match bitrate {
"1 Mbit/s" => Some(Baudrate::Baud1M),
"800 kbit/s" => Some(Baudrate::Baud800K),
"500 kbit/s" => Some(Baudrate::Baud500K),
"250 kbit/s" => Some(Baudrate::Baud250K),
"125 kbit/s" => Some(Baudrate::Baud125K),
"100 kbit/s" => Some(Baudrate::Baud100K),
"95.238 kbit/s" => Some(Baudrate::Baud95K),
"83.333 kbit/s" => Some(Baudrate::Baud83),
"50 kbit/s" => Some(Baudrate::Baud50K),
"47.619 kbit/s" => Some(Baudrate::Baud47K),
"33.333 kbit/s" => Some(Baudrate::Baud33K),
"20 kbit/s" => Some(Baudrate::Baud20K),
"10 kbit/s" => Some(Baudrate::Baud10K),
"5 kbit/s" => Some(Baudrate::Baud5K),
_ => None,
}
}
4 changes: 1 addition & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ mod event_handler;
use can_dbc::DBC;
use event_handler::{CanHandler, DBCFile, Init, PacketFilter};
#[cfg(target_os = "windows")]
use pcan_basic::{
bus::UsbBus, hw::attached_channels as available_interfaces, socket::usb::UsbCanSocket,
};
use pcan_basic::{bus::UsbBus, socket::usb::UsbCanSocket};
#[cfg(target_os = "linux")]
use privilege_rs::privilege_request;
#[cfg(target_os = "windows")]
Expand Down
2 changes: 1 addition & 1 deletion ui/app.slint
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export component AppWindow inherits Window {
callback open_dbc_file();
callback filter_id(CanData, bool);
callback start(string, int, string);
title: @tr("CAN VIEWER (version 0.2.0)");
title: @tr("CAN VIEWER (version 0.2.2)");
icon: @image-url("images/can_viewer_128px.png");
background: #1a1f2b;
default-font-family: "Noto Sans";
Expand Down

0 comments on commit 788a001

Please sign in to comment.