serial.open
Open a serial port connection and obtain a connection ID for subsequent read, write, and control operations.
Instructions
Open a serial port connection. Returns a connection_id for use with other serial tools. The port stays open across tool calls until serial.close is called or the server exits. Defaults are 115200 baud, 8N1, \r\n line terminator — the most common settings. If you don't know the correct settings, check for a protocol spec with serial.spec.list or ask the user. Wrong baud rate is the most common cause of garbled data. After opening: 1) Use serial.spec.list to check for a matching protocol spec. If a match is found, attach it with serial.spec.attach. 2) Use serial.plugin.list to check for a plugin that matches the device. If a matching plugin is loaded, its tools are available to use directly. 3) Do a serial.read to check for any buffered data — many devices send a boot banner, prompt, or status message on connection.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| port | Yes | Serial port path (e.g. /dev/ttyUSB0, COM3). | |
| baudrate | No | Baud rate (default 115200). Common values: 9600, 19200, 38400, 57600, 115200. | |
| bytesize | No | Data bits (default 8). | |
| parity | No | Parity: N(one), E(ven), O(dd), M(ark), S(pace). Default N. | N |
| stopbits | No | Stop bits (default 1). | |
| timeout_ms | No | Read timeout in milliseconds (default 200). | |
| write_timeout_ms | No | Write timeout in milliseconds (default 200). | |
| exclusive | No | Request exclusive access (platform-dependent, ignored if unsupported). | |
| encoding | No | Default text encoding for this connection (default utf-8). | utf-8 |
| newline | No | Default line terminator for readline and append_newline (default \r\n). | \r\n |