cordova_serial.requestPermission() driver fix
Fight controller based on silabs CP2104 was not working as function call cordova_serial.requestPermission() without specify the driver parameter uses the default driver "CdcAcmSerialDriver" which is the wrong when usb-uart chip is a CP2104. This chip requires the driver "Cp21xxSerialDriver" fix code smells fix the automatically reported code smells 'CdcAcmSerialDriver' as default driver In order to not rely on the fallback driver in the driver library define 'CdcAcmSerialDriver' explicit locally Co-authored-by: haslinghuis <mark@numloq.nl> add CP2102 and other CP210x single port devices into usb device filter10.8-maintenance
parent
898a6b974b
commit
f4abe55308
|
@ -1,4 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<usb-device vendor-id="1155" product-id="22336" /> <!--STMicroelectronics / Virtual COM Port -->
|
<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>
|
</resources>
|
||||||
|
|
|
@ -60,6 +60,13 @@ const chromeapiSerial = {
|
||||||
stopBits: 'one',
|
stopBits: 'one',
|
||||||
ctsFlowControl: false,
|
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) {
|
setConnectionOptions: function(ConnectionOptions) {
|
||||||
if (ConnectionOptions.persistent) {
|
if (ConnectionOptions.persistent) {
|
||||||
this.connection.persistent = ConnectionOptions.persistent;
|
this.connection.persistent = ConnectionOptions.persistent;
|
||||||
|
@ -158,7 +165,7 @@ const chromeapiSerial = {
|
||||||
const vid = parseInt(pathSplit[0]);
|
const vid = parseInt(pathSplit[0]);
|
||||||
const pid = parseInt(pathSplit[1]);
|
const pid = parseInt(pathSplit[1]);
|
||||||
console.log(`${self.logHeader}request permission (vid=${vid} / pid=${pid})`);
|
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();
|
const options = self.getCordovaSerialConnectionOptions();
|
||||||
cordova_serial.open(options, function () {
|
cordova_serial.open(options, function () {
|
||||||
cordova_serial.registerReadCallback(function (data) {
|
cordova_serial.registerReadCallback(function (data) {
|
||||||
|
|
Loading…
Reference in New Issue