1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-25 01:05:15 +03:00

Extract out virtual serial (#3998)

* Extract old virtual serial for compatability

* Update src/js/virtualSerial.js

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>

---------

Co-authored-by: nerdCopter <56646290+nerdCopter@users.noreply.github.com>
Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
This commit is contained in:
Tomas Chmelevskij 2024-07-10 21:21:49 +02:00 committed by GitHub
parent dc1e86262e
commit 3cffa09ae3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 73 additions and 689 deletions

43
src/js/virtualSerial.js Normal file
View file

@ -0,0 +1,43 @@
const VIRTUAL = "virtual";
/**
* Stripped down version of our nwjs based serial port implementation
* which is required to still have virtual serial port support in the
* browser.
*/
class VirtualSerial {
constructor() {
this.connected = false;
this.connectionId = false;
this.openCanceled = false;
this.bitrate = 0;
this.bytesReceived = 0;
this.bytesSent = 0;
this.failed = 0;
this.connectionType = VIRTUAL;
this.transmitting = false;
this.outputBuffer = [];
}
connect(callback) {
if (!this.openCanceled) {
this.connected = true;
this.connectionId = VIRTUAL;
this.bitrate = 115200;
callback();
}
}
disconnect(callback) {
this.connected = false;
this.outputBuffer = [];
this.transmitting = false;
if (this.connectionId) {
this.connectionId = false;
this.bitrate = 0;
if (callback) {
callback(true);
}
}
}
}
export default new VirtualSerial();