Auto merged - #2441 at Wed, 16 Jun 2021 20:25:25 GMT

cordova_serial.requestPermission() driver fix
10.8-maintenance
J Blackman 2021-06-17 06:25:26 +10:00 committed by GitHub
commit 235cf5cf8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<usb-device vendor-id="1155" product-id="22336" /> <!--STMicroelectronics / Virtual COM Port -->
<usb-device vendor-id="4292" product-id="60000" /> <!--CP2102 and other CP210x single port devices -->
</resources>

View File

@ -60,6 +60,13 @@ const chromeapiSerial = {
stopBits: 'one',
ctsFlowControl: false,
},
getDriver: function(vid, pid) {
if (vid === 4292 && pid === 60000) {
return 'Cp21xxSerialDriver'; //for Silabs CP2102 and all other CP210x
} else {
return 'CdcAcmSerialDriver';
}
},
setConnectionOptions: function(ConnectionOptions) {
if (ConnectionOptions.persistent) {
this.connection.persistent = ConnectionOptions.persistent;
@ -158,7 +165,7 @@ const chromeapiSerial = {
const vid = parseInt(pathSplit[0]);
const pid = parseInt(pathSplit[1]);
console.log(`${self.logHeader}request permission (vid=${vid} / pid=${pid})`);
cordova_serial.requestPermission({vid: vid, pid: pid}, function() {
cordova_serial.requestPermission({vid: vid, pid: pid, driver: self.getDriver(vid, pid)}, function() {
const options = self.getCordovaSerialConnectionOptions();
cordova_serial.open(options, function () {
cordova_serial.registerReadCallback(function (data) {