Skip to content

Commit

Permalink
Bug Fixes
Browse files Browse the repository at this point in the history
Was matching on partial matches.
Was printing out too many dividers.
Added settings.json to gitignore
  • Loading branch information
schiltz3 committed Jan 29, 2024
1 parent 4597297 commit cf38128
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,4 @@ Cargo.lock

/target


# Added by cargo
#
# already existing elements were commented out

#/target
settings.json
14 changes: 11 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,17 @@ fn alias_com_port_eq(serial_port_info: &UsbPortInfo, com_port: &ComPort) -> bool
if serial_port_info.pid == com_port.product_id {
matched = matched && true;
matched_element += 1;
} else {
matched = false;
}

match serial_port_info.serial_number.borrow() {
Some(s) => {
if s == &com_port.serial_number {
matched = matched && true;
matched_element += 1;
} else {
matched = false;
}
}
None => {}
Expand All @@ -114,6 +118,8 @@ fn alias_com_port_eq(serial_port_info: &UsbPortInfo, com_port: &ComPort) -> bool
if m == mn {
matched = matched && true;
matched_element += 1;
} else {
matched = false;
}
}
None => {}
Expand All @@ -127,7 +133,9 @@ fn alias_com_port_eq(serial_port_info: &UsbPortInfo, com_port: &ComPort) -> bool
if pn == &remove_last_word(p) {
matched = matched && true;
matched_element += 1;
};
} else {
matched = false;
}
}
None => {}
},
Expand Down Expand Up @@ -195,7 +203,6 @@ fn print_ports(ports: Vec<SerialPortInfo>, settings: &Settings) {
skip_printing = true;
println!("-------");
println!("{} {}", port.port_name, com_port_alias.alias);
println!("-------");
}
}
}
Expand All @@ -214,13 +221,14 @@ fn print_ports(ports: Vec<SerialPortInfo>, settings: &Settings) {
"\tSerial Number: {}",
usbinfo.serial_number.clone().unwrap_or_default()
);
println!("-------");
}
}
_ => {}
}
}
if serial_port_count == 0 {
println!("No COM ports found.")
} else {
println!("-------");
}
}

0 comments on commit cf38128

Please sign in to comment.