1
mirror of https://github.com/flipperdevices/flipperzero-firmware.git synced 2025-12-13 05:19:50 +04:00

Add guides on Getting Started with JS (#4150)

- Get started section added to the JS docs
- Small fixes in the JS modules docs
This commit is contained in:
Ruslan Nadyrshin
2025-03-18 20:08:23 +04:00
committed by GitHub
parent 9a8dcc340f
commit 02dedd60f3
25 changed files with 343 additions and 123 deletions

View File

@@ -1,6 +1,5 @@
# js_serial {#js_serial}
# Serial module {#js_serial}
# Serial module
```js
let serial = require("serial");
```
@@ -20,7 +19,7 @@ serial.setup("lpuart", 115200);
```
## write
Write data to serial port
Write data to serial port.
### Parameters
One or more arguments of the following types:
@@ -41,7 +40,7 @@ Read a fixed number of characters from serial port.
### Parameters
- Number of bytes to read
- (optional) Timeout value in ms
- *(optional)* Timeout value in ms
### Returns
A sting of received characters or undefined if nothing was received before timeout.
@@ -53,10 +52,10 @@ serial.read(10, 5000); // Read 10 bytes, with 5s timeout
```
## readln
Read from serial port until line break character
Read from serial port until line break character.
### Parameters
(optional) Timeout value in ms
*(optional)* Timeout value in ms.
### Returns
A sting of received characters or undefined if nothing was received before timeout.
@@ -68,11 +67,11 @@ serial.readln(5000); // Read with 5s timeout
```
## readBytes
Read from serial port until line break character
Read from serial port until line break character.
### Parameters
- Number of bytes to read
- (optional) Timeout value in ms
- *(optional)* Timeout value in ms
### Returns
ArrayBuffer with received data or undefined if nothing was received before timeout.
@@ -86,13 +85,13 @@ serial.readBytes(1, 0);
```
## expect
Search for a string pattern in received data stream
Search for a string pattern in received data stream.
### Parameters
- Single argument or array of the following types:
- A string
- Array of numbers, each number is interpreted as a byte
- (optional) Timeout value in ms
- *(optional)* Timeout value in ms
### Returns
Index of matched pattern in input patterns list, undefined if nothing was found.