Skip to content

Commit 9b080c3

Browse files
authored
Auto merged - #2677 at Wed, 08 Dec 2021 11:17:12 GMT
[BUG-FIX] Fix Port Detection using VID/PID
2 parents 173c467 + 706a239 commit 9b080c3

File tree

5 files changed

+47
-6
lines changed

5 files changed

+47
-6
lines changed

locales/en/messages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@
105105
"message": "Set connection timeout to allow longer initialisation on device plugin or reboot",
106106
"description": "Change timeout on auto-connect and reboot so the bus has more time to initialize after being detected by the system"
107107
},
108+
"showAllSerialDevices": {
109+
"message": "Show all serial devices (for manufacturers or development)",
110+
"description": "Do not filter serial devices using VID/PID values (for manufacturers or development)"
111+
},
108112
"cordovaForceComputerUI": {
109113
"message": "Use computers interface instead of phones interface"
110114
},

src/js/port_handler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
const TIMEOUT_CHECK = 500 ; // With 250 it seems that it produces a memory leak and slowdown in some versions, reason unknown
44

55
const usbDevices = { filters: [
6-
{'vendorId': 1155, 'productId': 57105},
7-
{'vendorId': 10473, 'productId': 393},
6+
{'vendorId': 1155, 'productId': 57105}, // STM Device in DFU Mode || Digital Radio in USB mode
7+
{'vendorId': 10473, 'productId': 393}, // GD32 DFU Bootloader
88
] };
99

1010
const PortHandler = new function () {

src/js/serial.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ const serial = {
1515
transmitting: false,
1616
outputBuffer: [],
1717

18+
serialDevices: [
19+
{'vendorId': 1027, 'productId': 24577}, // FT232R USB UART
20+
{'vendorId': 1155, 'productId': 22336}, // STM Electronics Virtual COM Port
21+
{'vendorId': 4292, 'productId': 60000}, // CP210x
22+
{'vendorId': 4292, 'productId': 60001}, // CP210x
23+
{'vendorId': 4292, 'productId': 60002}, // CP210x
24+
],
25+
1826
connect: function (path, options, callback) {
1927
const self = this;
2028
const testUrl = path.match(/^tcp:\/\/([A-Za-z0-9\.-]+)(?:\:(\d+))?$/);
@@ -258,13 +266,24 @@ const serial = {
258266
}
259267
},
260268
getDevices: function (callback) {
269+
const self = this;
270+
261271
chrome.serial.getDevices(function (devices_array) {
262272
const devices = [];
273+
let showAllSerialDevices = false;
274+
263275
devices_array.forEach(function (device) {
264-
devices.push({
265-
path: device.path,
266-
displayName: device.displayName,
267-
});
276+
ConfigStorage.get('showAllSerialDevices', res => showAllSerialDevices = res.showAllSerialDevices);
277+
const isKnownSerialDevice = self.serialDevices.some(el => el.vendorId === device.vendorId) && self.serialDevices.some(el => el.productId === device.productId);
278+
279+
if (isKnownSerialDevice || showAllSerialDevices) {
280+
devices.push({
281+
path: device.path,
282+
displayName: device.displayName,
283+
vendorId: device.vendorId,
284+
productId: device.productId,
285+
});
286+
}
268287
});
269288

270289
callback(devices);

src/js/tabs/options.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ options.initialize = function (callback) {
1515
TABS.options.initAnalyticsOptOut();
1616
TABS.options.initCliAutoComplete();
1717
TABS.options.initAutoConnectConnectionTimeout();
18+
TABS.options.initShowAllSerialDevices();
1819
TABS.options.initCordovaForceComputerUI();
1920
TABS.options.initDarkTheme();
2021

@@ -133,6 +134,17 @@ options.initAutoConnectConnectionTimeout = function () {
133134
});
134135
};
135136

137+
options.initShowAllSerialDevices = function() {
138+
const showAllSerialDevicesElement = $('div.showAllSerialDevices input');
139+
ConfigStorage.get('showAllSerialDevices', result => {
140+
showAllSerialDevicesElement
141+
.prop('checked', !!result.showAllSerialDevices)
142+
.on('change', () => ConfigStorage.set({ showAllSerialDevices: showAllSerialDevicesElement.is(':checked') }))
143+
.trigger('change');
144+
});
145+
146+
};
147+
136148
options.initCordovaForceComputerUI = function () {
137149
if (GUI.isCordova() && cordovaUI.canChangeUI) {
138150
ConfigStorage.get('cordovaForceComputerUI', function (result) {

src/tabs/options.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
</select>
4747
<span i18n="connectionTimeout"></span>
4848
</div>
49+
<div class="showAllSerialDevices margin-bottom">
50+
<div>
51+
<input type="checkbox" class="toggle" />
52+
</div>
53+
<span class="freelabel" i18n="showAllSerialDevices"></span>
54+
</div>
4955
<div class="cordovaForceComputerUI margin-bottom">
5056
<div>
5157
<input type="checkbox" class="toggle" />

0 commit comments

Comments
 (0)