Skip to content

Commit 1415fcd

Browse files
committed
Fix no COM port #2325
Signed-off-by: Gareth Hancock <[email protected]>
1 parent d0f9881 commit 1415fcd

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/bindings/src/serialport_win.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,15 +792,18 @@ void ListBaton::Execute() {
792792
char *name;
793793
char *manufacturer;
794794
char *locationId;
795+
char *friendlyName;
795796
char serialNumber[MAX_REGISTRY_KEY_SIZE];
796-
bool isCom = false;
797+
bool isCom;
797798
while (true) {
798799
pnpId = NULL;
799800
vendorId = NULL;
800801
productId = NULL;
801802
name = NULL;
802803
manufacturer = NULL;
803804
locationId = NULL;
805+
friendlyName = NULL;
806+
isCom = false;
804807

805808
ZeroMemory(&deviceInfoData, sizeof(SP_DEVINFO_DATA));
806809
deviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
@@ -835,6 +838,12 @@ void ListBaton::Execute() {
835838
sizeof(szBuffer), &dwSize)) {
836839
locationId = strdup(szBuffer);
837840
}
841+
if (SetupDiGetDeviceRegistryProperty(hDevInfo, &deviceInfoData,
842+
SPDRP_FRIENDLYNAME, &dwPropertyRegDataType,
843+
reinterpret_cast<BYTE*>(szBuffer),
844+
sizeof(szBuffer), &dwSize)) {
845+
friendlyName = strdup(szBuffer);
846+
}
838847
if (SetupDiGetDeviceRegistryProperty(hDevInfo, &deviceInfoData,
839848
SPDRP_MFG, &dwPropertyRegDataType,
840849
reinterpret_cast<BYTE*>(szBuffer),
@@ -866,6 +875,9 @@ void ListBaton::Execute() {
866875
if (locationId) {
867876
resultItem->locationId = locationId;
868877
}
878+
if (friendlyName) {
879+
resultItem->friendlyName = friendlyName;
880+
}
869881
results.push_back(resultItem);
870882
}
871883
free(pnpId);

packages/bindings/src/serialport_win.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct ListResultItem {
5454
std::string serialNumber;
5555
std::string pnpId;
5656
std::string locationId;
57+
std::string friendlyName;
5758
std::string vendorId;
5859
std::string productId;
5960
};
@@ -78,6 +79,7 @@ struct ListBaton : public Napi::AsyncWorker {
7879
setIfNotEmpty(item, "serialNumber", (*it)->serialNumber.c_str());
7980
setIfNotEmpty(item, "pnpId", (*it)->pnpId.c_str());
8081
setIfNotEmpty(item, "locationId", (*it)->locationId.c_str());
82+
setIfNotEmpty(item, "friendlyName", (*it)->friendlyName.c_str());
8183
setIfNotEmpty(item, "vendorId", (*it)->vendorId.c_str());
8284
setIfNotEmpty(item, "productId", (*it)->productId.c_str());
8385

0 commit comments

Comments
 (0)