-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Query registry for USB serial numbers in win #1483
Query registry for USB serial numbers in win #1483
Conversation
@@ -9,7 +9,7 @@ class WindowsBinding extends BaseBinding { | |||
return promisify(binding.list)().then(ports => { | |||
// Grab the serial number from the pnp id | |||
ports.forEach(port => { | |||
if (port.pnpId) { | |||
if (port.pnpId && !port.serialNumber) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/serialport_win.cpp
Outdated
|
||
// NOTE: Devices might have a containerUuid like {00000000-0000-0000-FFFF-FFFFFFFFFFFF} | ||
// This means they're non-removable, and are not handled (yet). | ||
// Maybe they should inherit the s/n from somewhere else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's non-removable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That means that the serial port is not part of what win32 considers a removable device. In other words: the RS-232 connector soldered to your motherboard.
src/serialport_win.cpp
Outdated
pnpId = strdup(szBuffer); | ||
|
||
pnpId = strdup(szBuffer); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: whitespace
cc @dustmop && @Fumon if you have some time, would you mind reviewing this? I'm not very good at reading c++ for errors. The logic seems ok for what I understand about querying the registry. @IvanSanchez are there any parts you'd like to highlight for review? |
@reconbot Just test that this works for whatever USB serial adapters you have lying around, specially if you have two or more of the same brand/model. This works for all the stuff in my test bench, but I'm not sure if there is any edge case that we overlooked. Luckily @CoqRogue did an over-the-shoulder review of the c++ code, but we'll appreciate extra eyes looking at it. |
Codecov Report
@@ Coverage Diff @@
## master #1483 +/- ##
=======================================
Coverage 79.04% 79.04%
=======================================
Files 21 21
Lines 940 940
Branches 170 170
=======================================
Hits 743 743
Misses 197 197
Continue to review full report at Codecov.
|
b9a0302
to
09218d3
Compare
Hey @IvanSanchez I want to land this but I landed your linting PR first and this doesn't pass anymore =x Mind rebasing? Thanks! |
Oh, the joys of linting. I'll have a look. |
afac78f
to
b6e7007
Compare
…rialport#1483) Serial numbers in win32 from USB devices cannot be readily derived from the PnP ID. This adds some logic to iterate through the win32 registry, as per the research in serialport#1459.
b6e7007
to
04ee499
Compare
Rebased, linted, and squashed. |
I'm getting a ton of compiler warnings from the last lint btw, it's
complaining about unsafe format strings (for Unix and Linux) Technically
it's correct. Idk if you'd like to take a wack at trying to correct them.
…On Wed, Feb 28, 2018, 4:59 AM Iván Sánchez Ortega ***@***.***> wrote:
Rebased, linted, and squashed.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1483 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABlbgHaXBoTqfdxRAIUvJ4wNhhPc5VQks5tZSOVgaJpZM4SHA4x>
.
|
🎉 |
🎉 Given the amount of rebasing and linting involved in getting this merged, I'd rather go into my usual "if it works, don't touch it" stance. 😁 |
New PR new PR. A format string is parsed for escape characters, I think we
could error on some device strings if they contain % signs.
…On Wed, Feb 28, 2018, 8:11 AM Iván Sánchez Ortega ***@***.***> wrote:
🎉
Given the amount of rebasing and linting involved in getting this merged,
I'd rather go into my usual "if it works, don't touch it" stance. 😁
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#1483 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABlbv9zUr8XS_JU_2yS8aQsk-Dnn0-sks5tZVCHgaJpZM4SHA4x>
.
|
…rialport#1483) Serial numbers in win32 from USB devices cannot be readily derived from the PnP ID. This adds some logic to iterate through the win32 registry, as per the research in serialport#1459.
Fixes #1459.
This PR makes the code for win32 fetch the ContainerID of the device node holding the serial port, then make a registry lookup for the composite USB device with a matching ContainerID. The serial number from the device node of the composite device is then returned and used.
The code might not be the cleanest ever, but it's in a working state.
Special kudos to @CoqRogue for all the work put on this.