Skip to content

Commit 3950949

Browse files
GazHankreconbot
authored andcommitted
Fix no COM port #2325
Signed-off-by: Gareth Hancock <64541249+GazHank@users.noreply.github.com>
1 parent 42d87d1 commit 3950949

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,8 +792,9 @@ 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
isCom = false;
799800
pnpId = NULL;
@@ -802,6 +803,8 @@ void ListBaton::Execute() {
802803
name = NULL;
803804
manufacturer = NULL;
804805
locationId = NULL;
806+
friendlyName = NULL;
807+
isCom = false;
805808

806809
ZeroMemory(&deviceInfoData, sizeof(SP_DEVINFO_DATA));
807810
deviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
@@ -836,6 +839,12 @@ void ListBaton::Execute() {
836839
sizeof(szBuffer), &dwSize)) {
837840
locationId = strdup(szBuffer);
838841
}
842+
if (SetupDiGetDeviceRegistryProperty(hDevInfo, &deviceInfoData,
843+
SPDRP_FRIENDLYNAME, &dwPropertyRegDataType,
844+
reinterpret_cast<BYTE*>(szBuffer),
845+
sizeof(szBuffer), &dwSize)) {
846+
friendlyName = strdup(szBuffer);
847+
}
839848
if (SetupDiGetDeviceRegistryProperty(hDevInfo, &deviceInfoData,
840849
SPDRP_MFG, &dwPropertyRegDataType,
841850
reinterpret_cast<BYTE*>(szBuffer),
@@ -867,6 +876,9 @@ void ListBaton::Execute() {
867876
if (locationId) {
868877
resultItem->locationId = locationId;
869878
}
879+
if (friendlyName) {
880+
resultItem->friendlyName = friendlyName;
881+
}
870882
results.push_back(resultItem);
871883
}
872884
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)