1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-18 13:55:14 +03:00

Fix Port Detection using VID/PID

This commit is contained in:
Mark Haslinghuis 2021-12-03 00:36:49 +01:00
parent 1497b544c1
commit 3562ed9d3a
No known key found for this signature in database
GPG key ID: 198B0F616296A584
2 changed files with 22 additions and 6 deletions

View file

@ -3,8 +3,8 @@
const TIMEOUT_CHECK = 500 ; // With 250 it seems that it produces a memory leak and slowdown in some versions, reason unknown
const usbDevices = { filters: [
{'vendorId': 1155, 'productId': 57105},
{'vendorId': 10473, 'productId': 393},
{'vendorId': 1155, 'productId': 57105}, // STM Device in DFU Mode || Digital Radio in USB mode
{'vendorId': 10473, 'productId': 393}, // GD32 DFU Bootloader
] };
const PortHandler = new function () {

View file

@ -15,6 +15,14 @@ const serial = {
transmitting: false,
outputBuffer: [],
serialDevices: [
{'vendorId': 1027, 'productId': 24577}, // FT232R USB UART
{'vendorId': 1155, 'productId': 22336}, // STM Electronics Virtual COM Port
{'vendorId': 4292, 'productId': 60000}, // CP210x
{'vendorId': 4292, 'productId': 60001}, // CP210x
{'vendorId': 4292, 'productId': 60002}, // CP210x
],
connect: function (path, options, callback) {
const self = this;
const testUrl = path.match(/^tcp:\/\/([A-Za-z0-9\.-]+)(?:\:(\d+))?$/);
@ -258,13 +266,21 @@ const serial = {
}
},
getDevices: function (callback) {
const self = this;
chrome.serial.getDevices(function (devices_array) {
const devices = [];
devices_array.forEach(function (device) {
const isFC = self.serialDevices.some(el => el.vendorId === device.vendorId) && self.serialDevices.some(el => el.productId === device.productId);
if (isFC) {
devices.push({
path: device.path,
displayName: device.displayName,
vendorId: device.vendorId,
productId: device.productId,
});
}
});
callback(devices);