{"id":15085856,"url":"https://github.com/s00d/tauri-plugin-serialplugin","last_synced_at":"2025-04-09T07:06:33.849Z","repository":{"id":220842423,"uuid":"752736476","full_name":"s00d/tauri-plugin-serialplugin","owner":"s00d","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-02T08:23:15.000Z","size":131991,"stargazers_count":32,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-03T02:34:00.454Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://crates.io/crates/tauri-plugin-serialplugin","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/s00d.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.spdx","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-04T17:03:44.000Z","updated_at":"2025-03-02T08:22:15.000Z","dependencies_parsed_at":"2024-08-24T15:45:51.767Z","dependency_job_id":"1f294c4e-f5e1-4b27-8c2d-cc9bc020a249","html_url":"https://github.com/s00d/tauri-plugin-serialplugin","commit_stats":null,"previous_names":["s00d/tauri-plugin-serialplugin"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Ftauri-plugin-serialplugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Ftauri-plugin-serialplugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Ftauri-plugin-serialplugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Ftauri-plugin-serialplugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s00d","download_url":"https://codeload.github.com/s00d/tauri-plugin-serialplugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994121,"owners_count":21030050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-25T07:01:40.192Z","updated_at":"2025-04-09T07:06:33.831Z","avatar_url":"https://github.com/s00d.png","language":"Rust","funding_links":[],"categories":["Development"],"sub_categories":["Plugins"],"readme":"[![npm version](https://img.shields.io/npm/v/tauri-plugin-serialplugin/latest?style=for-the-badge)](https://www.npmjs.com/package/tauri-plugin-serialplugin)\n[![Crates.io](https://img.shields.io/crates/v/tauri-plugin-serialplugin?style=for-the-badge)](https://crates.io/crates/tauri-plugin-serialplugin)\n[![GitHub issues](https://img.shields.io/github/issues/s00d/tauri-plugin-serialplugin?style=for-the-badge)](https://github.com/s00d/tauri-plugin-serialplugin/issues)\n[![GitHub stars](https://img.shields.io/github/stars/s00d/tauri-plugin-serialplugin?style=for-the-badge)](https://github.com/s00d/tauri-plugin-serialplugin/stargazers)\n[![Donate](https://img.shields.io/badge/Donate-Donationalerts-ff4081?style=for-the-badge)](https://www.donationalerts.com/r/s00d88)\n\n# Tauri Plugin — SerialPort\n\nA comprehensive plugin for Tauri applications to communicate with serial ports. This plugin provides a complete API for reading from and writing to serial devices, with support for various configuration options and control signals.\n\n---\n\n## Table of Contents\n\n1. [Installation](#installation)\n2. [Basic Usage](#basic-usage)\n3. [Permissions](#permissions)\n4. [API Reference](#api-reference)  \n   4.1. [Port Discovery](#port-discovery)  \n   4.2. [Connection Management](#connection-management)  \n   4.3. [Data Transfer](#data-transfer)  \n   4.4. [Port Configuration](#port-configuration)  \n   4.5. [Control Signals](#control-signals)  \n   4.6. [Buffer Management](#buffer-management)\n5. [Common Use Cases](#common-use-cases)\n6. [Android Setup](#android-setup)\n7. [Contributing](#contributing)\n8. [Development Setup](#development-setup)\n9. [Partners](#partners)\n10. [License](#license)\n\n---\n\n## Installation\n\n### Prerequisites\n\n- **Rust** version 1.70 or higher\n- **Tauri** 2.0 or higher\n- **Node.js** and an npm-compatible package manager (npm, yarn, pnpm)\n\n### Installation Methods\n\n**Using crates.io and npm (Recommended)**\n\n```bash\n# Install the Rust dependency\ncargo add tauri-plugin-serialplugin\n```\n\n```bash\n# Install JavaScript bindings\nnpm add tauri-plugin-serialplugin\n# or\nyarn add tauri-plugin-serialplugin\n# or\npnpm add tauri-plugin-serialplugin\n```\n\n---\n\n## Basic Usage\n\n1. **Register the Plugin**\n   ```rust\n   // src-tauri/src/main.rs\n   fn main() {\n       tauri::Builder::default()\n           .plugin(tauri_plugin_serialplugin::init())\n           .run(tauri::generate_context!())\n           .expect(\"error while running tauri application\");\n   }\n   ```\n\n2. **Configure Permissions**\n   ```jsonc\n   // src-tauri/capabilities/default.json\n   {\n     \"$schema\": \"../gen/schemas/desktop-schema.json\",\n     \"identifier\": \"default\",\n     \"description\": \"Capability for the main window\",\n     \"windows\": [\"main\"],\n     \"permissions\": [\n       \"core:default\",\n       \"serialplugin:default\"\n     ]\n   }\n   ```\n\n3. **Basic Example**\n   ```typescript\n   import { SerialPort } from \"tauri-plugin-serialplugin\";\n\n   // List available ports\n   const ports = await SerialPort.available_ports();\n   console.log(\"Available ports:\", ports);\n\n   // Open a port\n   const port = new SerialPort({\n     path: \"COM1\",\n     baudRate: 9600\n   });\n   await port.open();\n\n   // Write data\n   await port.write(\"Hello, Serial Port!\");\n\n   // Start port listening\n   await port.startListening();\n\n   // Read data with event listener\n   await port.listen((data) =\u003e {\n     console.log(\"Received:\", data);\n   });\n\n   // Stop port listening\n   await port.stopListening();\n\n   // Close port\n   await port.close();\n   ```\n\n---\n\n## Permissions\n\nBelow is a list of all permissions the plugin supports. Granting or denying them allows fine-grained control over what your application can do with serial ports.\n\n| Permission                                  | Description                                                                   |\n|---------------------------------------------|-------------------------------------------------------------------------------|\n| `serialplugin:allow-available-ports`        | Allows listing of available serial ports                                      |\n| `serialplugin:deny-available-ports`         | Denies listing of available serial ports                                      |\n| `serialplugin:allow-cancel-read`            | Allows canceling of read operations                                           |\n| `serialplugin:deny-cancel-read`             | Denies canceling of read operations                                           |\n| `serialplugin:allow-close`                  | Allows closing of serial ports                                                |\n| `serialplugin:deny-close`                   | Denies closing of serial ports                                                |\n| `serialplugin:allow-close-all`              | Allows closing of all open serial ports                                       |\n| `serialplugin:deny-close-all`               | Denies closing of all open serial ports                                       |\n| `serialplugin:allow-force-close`            | Allows forcefully closing of serial ports                                     |\n| `serialplugin:deny-force-close`             | Denies forcefully closing of serial ports                                     |\n| `serialplugin:allow-open`                   | Allows opening of serial ports                                                |\n| `serialplugin:deny-open`                    | Denies opening of serial ports                                                |\n| `serialplugin:allow-read`                   | Allows reading data from serial ports                                         |\n| `serialplugin:deny-read`                    | Denies reading data from serial ports                                         |\n| `serialplugin:allow-read-binary`            | Allows reading binary data from serial ports                                  |\n| `serialplugin:deny-read-binary`             | Denies reading binary data from serial ports                                  |\n| `serialplugin:allow-write`                  | Allows writing data to serial ports                                           |\n| `serialplugin:deny-write`                   | Denies writing data to serial ports                                           |\n| `serialplugin:allow-write-binary`           | Allows writing binary data to serial ports                                    |\n| `serialplugin:deny-write-binary`            | Denies writing binary data to serial ports                                    |\n| `serialplugin:allow-available-ports-direct` | Enables the `available_ports_direct` command without any pre-configured scope |\n| `serialplugin:deny-available-ports-direct`  | Denies the `available_ports_direct` command without any pre-configured scope  |\n| `serialplugin:allow-set-baud-rate`          | Allows changing the baud rate of serial ports                                 |\n| `serialplugin:deny-set-baud-rate`           | Denies changing the baud rate of serial ports                                 |\n| `serialplugin:allow-set-data-bits`          | Allows changing the data bits configuration                                   |\n| `serialplugin:deny-set-data-bits`           | Denies changing the data bits configuration                                   |\n| `serialplugin:allow-set-flow-control`       | Allows changing the flow control mode                                         |\n| `serialplugin:deny-set-flow-control`        | Denies changing the flow control mode                                         |\n| `serialplugin:allow-set-parity`             | Allows changing the parity checking mode                                      |\n| `serialplugin:deny-set-parity`              | Denies changing the parity checking mode                                      |\n| `serialplugin:allow-set-stop-bits`          | Allows changing the stop bits configuration                                   |\n| `serialplugin:deny-set-stop-bits`           | Denies changing the stop bits configuration                                   |\n| `serialplugin:allow-set-timeout`            | Allows changing the timeout duration                                          |\n| `serialplugin:deny-set-timeout`             | Denies changing the timeout duration                                          |\n| `serialplugin:allow-write-rts`              | Allows setting the RTS (Request To Send) control signal                       |\n| `serialplugin:deny-write-rts`               | Denies setting the RTS control signal                                         |\n| `serialplugin:allow-write-dtr`              | Allows setting the DTR (Data Terminal Ready) control signal                   |\n| `serialplugin:deny-write-dtr`               | Denies setting the DTR control signal                                         |\n| `serialplugin:allow-read-cts`               | Allows reading the CTS (Clear To Send) control signal state                   |\n| `serialplugin:deny-read-cts`                | Denies reading the CTS control signal state                                   |\n| `serialplugin:allow-read-dsr`               | Allows reading the DSR (Data Set Ready) control signal state                  |\n| `serialplugin:deny-read-dsr`                | Denies reading the DSR control signal state                                   |\n| `serialplugin:allow-read-ri`                | Allows reading the RI (Ring Indicator) control signal state                   |\n| `serialplugin:deny-read-ri`                 | Denies reading the RI control signal state                                    |\n| `serialplugin:allow-read-cd`                | Allows reading the CD (Carrier Detect) control signal state                   |\n| `serialplugin:deny-read-cd`                 | Denies reading the CD control signal state                                    |\n| `serialplugin:allow-bytes-to-read`          | Allows checking the number of bytes available to read                         |\n| `serialplugin:deny-bytes-to-read`           | Denies checking the number of bytes available to read                         |\n| `serialplugin:allow-bytes-to-write`         | Allows checking the number of bytes waiting to be written                     |\n| `serialplugin:deny-bytes-to-write`          | Denies checking the number of bytes waiting to be written                     |\n| `serialplugin:allow-clear-buffer`           | Allows clearing input/output buffers                                          |\n| `serialplugin:deny-clear-buffer`            | Denies clearing input/output buffers                                          |\n| `serialplugin:allow-set-break`              | Allows starting break signal transmission                                     |\n| `serialplugin:deny-set-break`               | Denies starting break signal transmission                                     |\n| `serialplugin:allow-clear-break`            | Allows stopping break signal transmission                                     |\n| `serialplugin:deny-clear-break`             | Denies stopping break signal transmission                                     |\n| `serialplugin:allow-start-listening`        | Allows starting automatic port monitoring and data listening                  |\n| `serialplugin:deny-start-listening`         | Denies starting automatic port monitoring and data listening                  |\n| `serialplugin:allow-stop-listening`         | Allows stopping automatic port monitoring and data listening                  |\n| `serialplugin:deny-stop-listening`          | Denies stopping automatic port monitoring and data listening                  |\n\n### Granting All Permissions (Example)\n\n```jsonc\n\"permissions\": [\n  \"core:default\",\n  \"serialplugin:default\",\n  \"serialplugin:allow-available-ports\",\n  \"serialplugin:allow-cancel-read\",\n  \"serialplugin:allow-close\",\n  \"serialplugin:allow-close-all\",\n  \"serialplugin:allow-force-close\",\n  \"serialplugin:allow-open\",\n  \"serialplugin:allow-read\",\n  \"serialplugin:allow-write\",\n  \"serialplugin:allow-write-binary\",\n  \"serialplugin:allow-available-ports-direct\",\n  \"serialplugin:allow-set-baud-rate\",\n  \"serialplugin:allow-set-data-bits\",\n  \"serialplugin:allow-set-flow-control\",\n  \"serialplugin:allow-set-parity\",\n  \"serialplugin:allow-set-stop-bits\",\n  \"serialplugin:allow-set-timeout\",\n  \"serialplugin:allow-write-rts\",\n  \"serialplugin:allow-write-dtr\",\n  \"serialplugin:allow-read-cts\",\n  \"serialplugin:allow-read-dsr\",\n  \"serialplugin:allow-read-ri\",\n  \"serialplugin:allow-read-cd\",\n  \"serialplugin:allow-bytes-to-read\",\n  \"serialplugin:allow-bytes-to-write\",\n  \"serialplugin:allow-clear-buffer\",\n  \"serialplugin:allow-set-break\",\n  \"serialplugin:allow-clear-break\",\n  \"serialplugin:allow-start-listening\",\n  \"serialplugin:allow-stop-listening\"\n]\n```\n\n---\n\n## API Reference\n\n### Port Discovery\n\n```typescript\nclass SerialPort {\n  /**\n   * Lists all available serial ports on the system\n   * @returns {Promise\u003c{[key: string]: PortInfo}\u003e} Map of port names to port information\n   * @example\n   * const ports = await SerialPort.available_ports();\n   * console.log(ports);\n   */\n  static async available_ports(): Promise\u003c{ [key: string]: PortInfo }\u003e;\n\n  /**\n   * Lists ports using platform-specific commands for enhanced detection\n   * @returns {Promise\u003c{[key: string]: PortInfo}\u003e} Map of port names to port information\n   * @example\n   * const ports = await SerialPort.available_ports_direct();\n   */\n  static async available_ports_direct(): Promise\u003c{ [key: string]: PortInfo }\u003e;\n\n  /**\n   * @description Lists all managed serial ports (ports that are currently open and managed by the application).\n   * @returns {Promise\u003cstring[]\u003e} A promise that resolves to an array of port paths (names).\n   */\n  static async managed_ports(): Promise\u003cstring[]\u003e;\n}\n```\n\n### Connection Management\n\n```typescript\nclass SerialPort {\n  /**\n   * Opens the serial port with specified configuration\n   * @returns {Promise\u003cvoid\u003e}\n   * @throws {Error} If port is already open or invalid configuration\n   * @example\n   * const port = new SerialPort({ path: \"COM1\", baudRate: 9600 });\n   * await port.open();\n   */\n  async open(): Promise\u003cvoid\u003e;\n\n  /**\n   * Closes the serial port connection\n   * @returns {Promise\u003cvoid\u003e}\n   * @throws {Error} If port is not open\n   * @example\n   * await port.close();\n   */\n  async close(): Promise\u003cvoid\u003e;\n\n  /**\n   * Starts listening for data on the serial port\n   * @returns {Promise\u003cvoid\u003e} A promise that resolves when listening starts\n   * @throws {Error} If starting listener fails or port is not open\n   * @example\n   * await port.startListening();\n   *\n   * // Listen for data events\n   * port.listen((data) =\u003e {\n   *   console.log(\"Data received:\", data);\n   * });\n   */\n  async startListening(): Promise\u003cvoid\u003e;\n\n  /**\n   * Stops listening for data on the serial port\n   * @returns {Promise\u003cvoid\u003e} A promise that resolves when listening stops\n   * @throws {Error} If stopping listener fails or port is not open\n   * @example\n   * await port.stopListening();\n   */\n  async stopListening(): Promise\u003cvoid\u003e;\n\n  /**\n   * Forces a serial port to close regardless of its state\n   * @param {string} path Port path to force close\n   * @returns {Promise\u003cvoid\u003e}\n   * @example\n   * await SerialPort.forceClose(\"COM1\");\n   */\n  static async forceClose(path: string): Promise\u003cvoid\u003e;\n\n  /**\n   * Closes all open serial port connections\n   * @returns {Promise\u003cvoid\u003e}\n   * @example\n   * await SerialPort.closeAll();\n   */\n  static async closeAll(): Promise\u003cvoid\u003e;\n}\n```\n\n### Data Transfer\n\n```typescript\nclass SerialPort {\n  /**\n   * Writes string data to the serial port\n   * @param {string} data Data to write\n   * @returns {Promise\u003cnumber\u003e} Number of bytes written\n   * @throws {Error} If write fails or port is not open\n   * @example\n   * const bytesWritten = await port.write(\"Hello\");\n   */\n  async write(data: string): Promise\u003cnumber\u003e;\n\n  /**\n   * Reads data from the serial port\n   * @param {ReadOptions} [options] Read options\n   * @returns {Promise\u003cstring\u003e} A promise that resolves to a string\n   */\n  async read(options?: ReadOptions): Promise\u003cstring\u003e;\n\n  /**\n   * Reads binary data from the serial port\n   * @param {ReadOptions} [options] Read options\n   * @returns {Promise\u003cUint8Array\u003e} A promise that resolves with binary data\n   */\n  async readBinary(options?: ReadOptions): Promise\u003cUint8Array\u003e;\n\n  /**\n   * Writes binary data to the serial port\n   * @param {Uint8Array | number[]} data Binary data to write\n   * @returns {Promise\u003cnumber\u003e} Number of bytes written\n   * @throws {Error} If write fails or port is not open\n   * @example\n   * const data = new Uint8Array([0x01, 0x02, 0x03]);\n   * const bytesWritten = await port.writeBinary(data);\n   */\n  async writeBinary(data: Uint8Array | number[]): Promise\u003cnumber\u003e;\n\n  /**\n   * Sets up a listener for incoming data\n   * @param {(data: string | Uint8Array) =\u003e void} callback Function to handle received data\n   * @param {boolean} [decode=true] Whether to decode data as string (true) or return raw bytes (false)\n   * @returns {Promise\u003cvoid\u003e}\n   * @example\n   * await port.listen((data) =\u003e {\n   *   console.log(\"Received:\", data);\n   * });\n   */\n  async listen(callback: (data: string | Uint8Array) =\u003e void, decode?: boolean): Promise\u003cvoid\u003e;\n}\n```\n\n### Port Configuration\n\n```typescript\nclass SerialPort {\n  /**\n   * Sets the baud rate\n   * @param {number} baudRate Speed in bits per second\n   * @returns {Promise\u003cvoid\u003e}\n   * @example\n   * await port.setBaudRate(115200);\n   */\n  async setBaudRate(baudRate: number): Promise\u003cvoid\u003e;\n\n  /**\n   * Sets the number of data bits\n   * @param {DataBits} dataBits Number of bits per character (5-8)\n   * @returns {Promise\u003cvoid\u003e}\n   * @example\n   * await port.setDataBits(DataBits.Eight);\n   */\n  async setDataBits(dataBits: DataBits): Promise\u003cvoid\u003e;\n\n  /**\n   * Sets the flow control mode\n   * @param {FlowControl} flowControl Flow control setting\n   * @returns {Promise\u003cvoid\u003e}\n   * @example\n   * await port.setFlowControl(FlowControl.Hardware);\n   */\n  async setFlowControl(flowControl: FlowControl): Promise\u003cvoid\u003e;\n\n  /**\n   * Sets the parity checking mode\n   * @param {Parity} parity Parity checking mode\n   * @returns {Promise\u003cvoid\u003e}\n   * @example\n   * await port.setParity(Parity.None);\n   */\n  async setParity(parity: Parity): Promise\u003cvoid\u003e;\n\n  /**\n   * Sets the number of stop bits\n   * @param {StopBits} stopBits Number of stop bits\n   * @returns {Promise\u003cvoid\u003e}\n   * @example\n   * await port.setStopBits(StopBits.One);\n   */\n  async setStopBits(stopBits: StopBits): Promise\u003cvoid\u003e;\n}\n```\n\n### Control Signals\n\n```typescript\nclass SerialPort {\n  /**\n   * Sets the RTS (Request to Send) signal\n   * @param {boolean} level Signal level (true = high, false = low)\n   * @returns {Promise\u003cvoid\u003e}\n   * @example\n   * await port.writeRequestToSend(true);\n   */\n  async writeRequestToSend(level: boolean): Promise\u003cvoid\u003e;\n\n  /**\n   * Sets the DTR (Data Terminal Ready) signal\n   * @param {boolean} level Signal level (true = high, false = low)\n   * @returns {Promise\u003cvoid\u003e}\n   * @example\n   * await port.writeDataTerminalReady(true);\n   */\n  async writeDataTerminalReady(level: boolean): Promise\u003cvoid\u003e;\n\n  /**\n   * Reads the CTS (Clear to Send) signal state\n   * @returns {Promise\u003cboolean\u003e} Signal state\n   * @example\n   * const cts = await port.readClearToSend();\n   */\n  async readClearToSend(): Promise\u003cboolean\u003e;\n\n  /**\n   * Reads the DSR (Data Set Ready) signal state\n   * @returns {Promise\u003cboolean\u003e} Signal state\n   * @example\n   * const dsr = await port.readDataSetReady();\n   */\n  async readDataSetReady(): Promise\u003cboolean\u003e;\n\n  /**\n   * Reads the RI (Ring Indicator) signal state\n   * @returns {Promise\u003cboolean\u003e} Signal state\n   * @example\n   * const ri = await port.readRingIndicator();\n   */\n  async readRingIndicator(): Promise\u003cboolean\u003e;\n\n  /**\n   * Reads the CD (Carrier Detect) signal state\n   * @returns {Promise\u003cboolean\u003e} Signal state\n   * @example\n   * const cd = await port.readCarrierDetect();\n   */\n  async readCarrierDetect(): Promise\u003cboolean\u003e;\n}\n```\n\n### Buffer Management\n\n```typescript\nclass SerialPort {\n  /**\n   * Gets number of bytes available to read\n   * @returns {Promise\u003cnumber\u003e} Number of bytes in read buffer\n   * @example\n   * const available = await port.bytesToRead();\n   */\n  async bytesToRead(): Promise\u003cnumber\u003e;\n\n  /**\n   * Gets number of bytes waiting to be written\n   * @returns {Promise\u003cnumber\u003e} Number of bytes in write buffer\n   * @example\n   * const pending = await port.bytesToWrite();\n   */\n  async bytesToWrite(): Promise\u003cnumber\u003e;\n\n  /**\n   * Clears the specified buffer\n   * @param {ClearBuffer} buffer Buffer to clear\n   * @returns {Promise\u003cvoid\u003e}\n   * @example\n   * await port.clearBuffer(ClearBuffer.Input);\n   */\n  async clearBuffer(buffer: ClearBuffer): Promise\u003cvoid\u003e;\n}\n```\n\n---\n\n## Common Use Cases\n\n### Reading Sensor Data\n\n```typescript\nconst port = new SerialPort({\n  path: \"COM1\",\n  baudRate: 9600\n});\n\nawait port.open();\nawait port.listen((data) =\u003e {\n  const sensorValue = parseFloat(data);\n  console.log(\"Sensor reading:\", sensorValue);\n});\n```\n\n### Binary Protocol Communication\n\n```typescript\nconst port = new SerialPort({\n  path: \"COM1\",\n  baudRate: 115200\n});\n\nawait port.open();\n\n// Send command\nconst command = new Uint8Array([0x02, 0x01, 0x03]);\nawait port.writeBinary(command);\n\n// Read response (raw bytes)\nawait port.listen((data) =\u003e {\n  const response = data instanceof Uint8Array ? data : new Uint8Array();\n  console.log(\"Response:\", response);\n}, false);\n```\n\n### Modbus Communication\n\n```typescript\nconst port = new SerialPort({\n   path: \"COM1\",\n   baudRate: 9600,\n   dataBits: DataBits.Eight,\n   stopBits: StopBits.One,\n   parity: Parity.None\n});\n\nawait port.open();\n\nfunction createModbusRequest(address: number, length: number): Uint8Array {\n   return new Uint8Array([\n      0x01, // Device ID\n      0x03, // Function code: Read Holding Registers\n      address \u003e\u003e 8, address \u0026 0xFF,\n      length \u003e\u003e 8, length \u0026 0xFF\n   ]);\n}\n\n// Send Modbus request\nconst request = createModbusRequest(0x1000, 10);\nawait port.writeBinary(request);\n```\n\n---\n\n## Android Setup\n\nTo use this plugin on Android, you need to add the JitPack repository to your project's `build.gradle.kts` file located at `/src-tauri/gen/android/build.gradle.kts`. Below is an example of how to configure it:\n\n```kotlin\nbuildscript {\n    repositories {\n        // ...\n        maven { url = uri(\"https://jitpack.io\") }\n    }\n    // ...\n}\n\nallprojects {\n    repositories {\n        // ...\n        maven { url = uri(\"https://jitpack.io\") }\n    }\n}\n```\n\n---\n\n## Contributing\n\nPull requests are welcome! Please read our contributing guidelines before you start.\n\n---\n\n## Development Setup\n\n```bash\ngit clone https://github.com/s00d/tauri-plugin-serialplugin.git\ncd tauri-plugin-serialplugin\n\npnpm i\npnpm run build\npnpm run playground\n```\n\n---\n\n## Partners\n\nIf you find this plugin valuable and would like to support further development, feel free to donate via [DonationAlerts](https://www.donationalerts.com/r/s00d88). Any contribution is greatly appreciated!\n\n---\n\n## License\n\nThis code is dual-licensed under MIT or Apache-2.0, where applicable, © 2019–2023 Tauri Programme within The Commons Conservancy.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs00d%2Ftauri-plugin-serialplugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs00d%2Ftauri-plugin-serialplugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs00d%2Ftauri-plugin-serialplugin/lists"}