Skip to content

Commit

Permalink
Fix no COM port #2325
Browse files Browse the repository at this point in the history
Signed-off-by: Gareth Hancock <64541249+GazHank@users.noreply.github.com>
  • Loading branch information
GazHank committed Oct 10, 2021
1 parent d0f9881 commit 1415fcd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/bindings/src/serialport_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,15 +792,18 @@ void ListBaton::Execute() {
char *name;
char *manufacturer;
char *locationId;
char *friendlyName;
char serialNumber[MAX_REGISTRY_KEY_SIZE];
bool isCom = false;
bool isCom;
while (true) {
pnpId = NULL;
vendorId = NULL;
productId = NULL;
name = NULL;
manufacturer = NULL;
locationId = NULL;
friendlyName = NULL;
isCom = false;

ZeroMemory(&deviceInfoData, sizeof(SP_DEVINFO_DATA));
deviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
Expand Down Expand Up @@ -835,6 +838,12 @@ void ListBaton::Execute() {
sizeof(szBuffer), &dwSize)) {
locationId = strdup(szBuffer);
}
if (SetupDiGetDeviceRegistryProperty(hDevInfo, &deviceInfoData,
SPDRP_FRIENDLYNAME, &dwPropertyRegDataType,
reinterpret_cast<BYTE*>(szBuffer),
sizeof(szBuffer), &dwSize)) {
friendlyName = strdup(szBuffer);
}
if (SetupDiGetDeviceRegistryProperty(hDevInfo, &deviceInfoData,
SPDRP_MFG, &dwPropertyRegDataType,
reinterpret_cast<BYTE*>(szBuffer),
Expand Down Expand Up @@ -866,6 +875,9 @@ void ListBaton::Execute() {
if (locationId) {
resultItem->locationId = locationId;
}
if (friendlyName) {
resultItem->friendlyName = friendlyName;
}
results.push_back(resultItem);
}
free(pnpId);
Expand Down
2 changes: 2 additions & 0 deletions packages/bindings/src/serialport_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct ListResultItem {
std::string serialNumber;
std::string pnpId;
std::string locationId;
std::string friendlyName;
std::string vendorId;
std::string productId;
};
Expand All @@ -78,6 +79,7 @@ struct ListBaton : public Napi::AsyncWorker {
setIfNotEmpty(item, "serialNumber", (*it)->serialNumber.c_str());
setIfNotEmpty(item, "pnpId", (*it)->pnpId.c_str());
setIfNotEmpty(item, "locationId", (*it)->locationId.c_str());
setIfNotEmpty(item, "friendlyName", (*it)->friendlyName.c_str());
setIfNotEmpty(item, "vendorId", (*it)->vendorId.c_str());
setIfNotEmpty(item, "productId", (*it)->productId.c_str());

Expand Down

0 comments on commit 1415fcd

Please sign in to comment.