Skip to content

Commit

Permalink
Tweak device detection to consider (vid, pid) combination, instead of…
Browse files Browse the repository at this point in the history
… just pid
  • Loading branch information
nilclass committed Feb 1, 2024
1 parent 6663b6f commit c3ac784
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions src/device_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ impl DeviceManager {
let mut found = vec![];

for (id, infos) in &mut by_usb_id {
let SerialPortType::UsbPort(UsbPortInfo { pid, .. }) = &infos[0].port_type else {
let SerialPortType::UsbPort(UsbPortInfo { vid, pid, .. }) = &infos[0].port_type else {
unreachable!()
};

if *pid == 0xACAB as u16 || *pid == 0x1312 as u16 {
if (*vid, *pid) == (0x1d50, 0xACAB) || (*vid, *pid) == (0xACAB, 0x1312) {
//it's now matching based on PID, which I have changed, so update your firmware
// remove "tty" ports on Mac OS (only use the "cu" ones)
fixup_mac_ports(infos);
Expand Down Expand Up @@ -160,25 +160,11 @@ impl DeviceManager {
}
}
} else {
//until serialport-rs supports product names, this just sets any connected ports, so hopefully you don't have anything else plugged in
let mut first = 0;

for info in infos {
if first == 0 {
found.push(FoundPort {
info: info.clone(),
// role: PortRole::JumperlessPrimary,
role: PortRole::Unknown,
});

first = 1;
} else {
found.push(FoundPort {
info: info.clone(),
// role: PortRole::JumperlessArduino,
role: PortRole::Unknown,
});
}
found.push(FoundPort {
info: info.clone(),
role: PortRole::Unknown,
});
}
}
}
Expand Down

0 comments on commit c3ac784

Please sign in to comment.