Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finds USB2CAN Serial Number by USB Name #1129

Merged
merged 2 commits into from Aug 6, 2022

Conversation

melloa
Copy link
Contributor

@melloa melloa commented Sep 17, 2021

PR changes the method of finding USB2CAN devices from querying all USB_ControllerDevices whose serial numbers start with "ED" to querying all CIM_LogicalDevices that contains the name "USB2CAN".

Background:
I recently bought a USB2CAN dongle from 8devices and it didn't show up in python-can. After looking through the source code, I realized it's because my dongle's serial number didn't start with "ED" (but did end with it) which is how python-can determines if a USB2CAN dongle is connected.

To make things more robust, I changed the query to find all devices that contain "USB2CAN" in their name and return the serial number by parsing the DeviceID which is in the format USB\<VID><PID>\<SERIAL_NUMBER>. I also kept the serial matching argument so users can select one if multiple are connected. I can also switch this to use the VID/PID of the dongle if that's more robust than the USB name.

@codecov
Copy link

codecov bot commented Sep 28, 2021

Codecov Report

Merging #1129 (eeff75c) into develop (596f07d) will decrease coverage by 0.00%.
The diff coverage is 85.71%.

@@             Coverage Diff             @@
##           develop    #1129      +/-   ##
===========================================
- Coverage    70.48%   70.48%   -0.01%     
===========================================
  Files           79       79              
  Lines         7677     7680       +3     
===========================================
+ Hits          5411     5413       +2     
- Misses        2266     2267       +1     

Copy link
Collaborator

@felixdivo felixdivo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't test it locally, but it looks like a good change.

@zariiii9003 zariiii9003 merged commit 616b00e into hardbyte:develop Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants