Skip to content

Commit 235cf5c

Browse files
authored
Auto merged - #2441 at Wed, 16 Jun 2021 20:25:25 GMT
cordova_serial.requestPermission() driver fix
2 parents 898a6b9 + f4abe55 commit 235cf5c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

cordova/usb_device_filter.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<usb-device vendor-id="1155" product-id="22336" /> <!--STMicroelectronics / Virtual COM Port -->
4+
<usb-device vendor-id="4292" product-id="60000" /> <!--CP2102 and other CP210x single port devices -->
45
</resources>

src/js/cordova_chromeapi.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ const chromeapiSerial = {
6060
stopBits: 'one',
6161
ctsFlowControl: false,
6262
},
63+
getDriver: function(vid, pid) {
64+
if (vid === 4292 && pid === 60000) {
65+
return 'Cp21xxSerialDriver'; //for Silabs CP2102 and all other CP210x
66+
} else {
67+
return 'CdcAcmSerialDriver';
68+
}
69+
},
6370
setConnectionOptions: function(ConnectionOptions) {
6471
if (ConnectionOptions.persistent) {
6572
this.connection.persistent = ConnectionOptions.persistent;
@@ -158,7 +165,7 @@ const chromeapiSerial = {
158165
const vid = parseInt(pathSplit[0]);
159166
const pid = parseInt(pathSplit[1]);
160167
console.log(`${self.logHeader}request permission (vid=${vid} / pid=${pid})`);
161-
cordova_serial.requestPermission({vid: vid, pid: pid}, function() {
168+
cordova_serial.requestPermission({vid: vid, pid: pid, driver: self.getDriver(vid, pid)}, function() {
162169
const options = self.getCordovaSerialConnectionOptions();
163170
cordova_serial.open(options, function () {
164171
cordova_serial.registerReadCallback(function (data) {

0 commit comments

Comments
 (0)