0

Describe the bug

I'm trying to run Serial lib on a ionic with capacitor. However, when executing the code, I'm obtaining the error Native: tried calling Serial.requestPermission, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator cordova_not_available.

Code

this.serial.requestPermission().then(() => {
           this.serial.open({
                     baudRate: 9800,
                     dataBits: 4,
                     stopBits: 1,
                     parity: 0,
                     dtr: true,
                     rts: true,
                     sleepOnPause: false
              }).then(() => {
            console.log('Serial connection opened');
            });
        }).catch((error: any) => console.log(error));
    }

To Reproduce

  1. Version of cordovarduino / cordova

"cordovarduino": "0.0.10", cordova - (not using, but for testing, tried to install it via npm install, but the error persisted. Keep in mind that this is not a cordova project, but a capacitor project)

  1. Type of board you use and code

Real Device : Herelink RC. Emulator: Pixel3 API 25

Expected behavior

Find an external device. When no USB is connected, 'USB not found' or something similar was expected.

Additional context

Note 1: On API 29 (Android 10) is working, but our real device (HereLink) just runs Android 7.1.2.

ionic info

Ionic:

Ionic CLI : 6.16.1 (/home/grolo/.nvm/versions/node/v14.16.1/lib/node_modules/@ionic/cli) Ionic Framework : @ionic/angular 5.6.7 @angular-devkit/build-angular : 0.1102.13 @angular-devkit/schematics : 11.2.13 @angular/cli : 11.2.13 @ionic/angular-toolkit : 3.1.1

Capacitor:

Capacitor CLI : 3.0.0 @capacitor/android : 3.0.2 @capacitor/core : 3.0.0 @capacitor/ios : 3.0.0

Utility:

cordova-res : not installed globally native-run (update available: 1.4.0) : 1.3.0

System:

NodeJS : v14.16.1 (/home/grolo/.nvm/versions/node/v14.16.1/bin/node) npm : 6.14.12 OS : Linux 5.4

1 Answer 1

0

Make sure to include cordova.js or run in a device/simulator cordova_not_available.

By focusing this error...i generally observe there is no error in our code function, methods, plugins .may be you are trying to run in your browser. Just connect USB and run in device. If this is not possible try to run in emulator create it from android studio..

like using of Location and Camera you need to run in device or simulator..

But Emulator may not get Respond as actual device do. Hope you understand what I want to explain you

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.