Skip to content

Commit e9aa024

Browse files
committed
Add setter for connection timeout
1 parent 4c58a74 commit e9aa024

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

libraries/Camera/extras/WebSerialCamera/serialConnectionHandler.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class SerialConnectionHandler {
2020
* @param {number} [stopBits=1] - The number of stop bits.
2121
* @param {string} [parity="none"] - The parity setting.
2222
* @param {string} [flowControl="none"] - The flow control setting.
23-
* @param {number} [bufferSize=2097152] - The size of the buffer in bytes. Max buffer size is 16MB
24-
* @param {number} [timeout=2000] - The connection timeout value in milliseconds.
23+
* @param {number} [bufferSize=2097152] - The size of the buffer in bytes. The default value is 2 MB. Max buffer size is 16MB.
24+
* @param {number} [timeout=2000] - The connection timeout value in milliseconds. The default value is 2000 ms.
2525
*/
2626
constructor(baudRate = 115200, dataBits = 8, stopBits = 1, parity = "none", flowControl = "none", bufferSize = 2 * 1024 * 1024, timeout = 2000) {
2727
this.baudRate = baudRate;
@@ -38,6 +38,14 @@ class SerialConnectionHandler {
3838
this.registerEvents();
3939
}
4040

41+
/**
42+
* Sets the connection timeout for the serial connection.
43+
* @param {number} timeout - The timeout value in milliseconds.
44+
*/
45+
setConnectionTimeout(timeout) {
46+
this.timeout = timeout;
47+
}
48+
4149
/**
4250
* Prompts the user to select a serial port.
4351
* @returns {Promise<SerialPort>} The serial port that the user has selected.

0 commit comments

Comments
 (0)