# serial

## getBuffer

Return data buffer.

**Returns:**

`CircularStringBuffer` - Data buffer.

## list

Returns list of available ports.

See <https://github.com/EmergingTechnologyAdvisors/node-serialport#module\\_serialport--SerialPort.list> for details about the structure of returned values.

**Returns:**

`Array.<Object>` - Array of port descriptions.

## open

Opens a serial port.

Data from the opened port will be automatically read line by line into a circular buffer. Once the buffer reaches it's maximum capacity specified by `bufferSize` argument, eldest entries are evicted to make room for new data.

\*\* Serial port properties with default values:\*\*

```json
{
 baudRate: 9600,
 dataBits: 8,        // Must be one of: 8, 7, 6, or 5.
 stopBits: 1,        // Must be one of: 1 or 2.
 parity: 'none'      // Must be one of: 'none', 'even', 'mark', 'odd', 'space'.
 rtscts: false,
 xon: false,
 xoff: false,
 xany: false
}
```

**Parameters:**

| Name         | Type     | Description                                                       |
| ------------ | -------- | ----------------------------------------------------------------- |
| `port`       | `String` | Path to serial port. E.g. '/dev/tty-usbserial1', 'COM5', etc.     |
| `opts`       | `Object` | Port properties.                                                  |
| `bufferSize` | `Number` | `optional` Size of the input data buffer. Default is 65536 bytes. |

**Returns:**

`SerialPort` - SerialPort object.

## waitForText

Waits for text to appear in the input data buffer.

Text pattern can be any of the supported string matching patterns(on the top of page).

**Parameters:**

| Name      | Type     | Description                                                |
| --------- | -------- | ---------------------------------------------------------- |
| `pattern` | `String` | Text pattern.                                              |
| `timeout` | `Number` | `optional` Timeout in milliseconds. Default is 60 seconds. |

## write

Write data to the port.

\*\* Usage example:\*\*

```javascript
serial.write('Hello\r\n');
```

**Parameters:**

| Name   | Type              | Description                                         |
| ------ | ----------------- | --------------------------------------------------- |
| `data` | `String`\|`Array` | Data to send. Either a string or an array of bytes. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.oxygenhq.org/download-installation-start/modules/module-serial.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
