summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorraldone01 <[email protected]>2025-07-26 10:11:20 +0200
committerraldone01 <[email protected]>2025-07-26 10:11:20 +0200
commitf36f97c45a58857ca3eb0a2f98f77f5931e72dae (patch)
tree954b6451138641dd691a4fa245aa66292b8f135b /examples
parent30d678970e4233ab41b40be8c8be31a0f02ccfb7 (diff)
More catches.
Diffstat (limited to 'examples')
-rw-r--r--examples/device/webusb_serial/website/serial.js34
1 files changed, 30 insertions, 4 deletions
diff --git a/examples/device/webusb_serial/website/serial.js b/examples/device/webusb_serial/website/serial.js
index b9c5c7827..55035c81f 100644
--- a/examples/device/webusb_serial/website/serial.js
+++ b/examples/device/webusb_serial/website/serial.js
@@ -21,7 +21,14 @@ class SerialPort {
} catch (error) {
console.error('Error disconnecting previous port:', error);
}
- await this._readLoopPromise;
+
+ if (this._readLoopPromise) {
+ try {
+ await this._readLoopPromise;
+ } catch (error) {
+ console.error('Error in read loop:', error);
+ }
+ }
this._readLoopPromise = null;
}
this._initialized = true;
@@ -95,7 +102,13 @@ class SerialPort {
console.error('Error closing port:', error);
}
- await this._readLoopPromise;
+ if (this._readLoopPromise) {
+ try {
+ await this._readLoopPromise;
+ } catch (error) {
+ console.error('Error in read loop:', error);
+ }
+ }
}
/// Send data to port
@@ -138,7 +151,14 @@ class WebUsbSerialPort {
} catch (error) {
console.error('Error disconnecting previous device:', error);
}
- await this._readLoopPromise;
+
+ if (this._readLoopPromise) {
+ try {
+ await this._readLoopPromise;
+ } catch (error) {
+ console.error('Error in read loop:', error);
+ }
+ }
this._readLoopPromise = null;
}
this._initialized = true;
@@ -228,7 +248,13 @@ class WebUsbSerialPort {
await this._device.releaseInterface(this._interfaceNumber);
- await this._readLoopPromise;
+ if (this._readLoopPromise) {
+ try {
+ await this._readLoopPromise;
+ } catch (error) {
+ console.error('Error in read loop:', error);
+ }
+ }
}
/// Send data to device