npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

capacitor-usb-serial

v1.0.3

Published

This capacitor plugin allows basic serial-over-usb functionality

Downloads

41

Readme

capacitor-usb-serial

This plugin provides a simple interface for USB serial communication in Capacitor applications. It allows you to connect to USB devices, send and receive data, and manage multiple device connections.

The plugin only supports Android devices and it uses usb-serial-for-android under the hood.

If you want to contribute the apple part feel free to open an issue / PR on the github repo.

Install

npm install capacitor-usb-serial
npx cap sync

API

Defines the interface for USB serial communication plugin

getDeviceHandlers()

getDeviceHandlers() => Promise<DeviceHandler[]>

Returns an array of DeviceHandler objects for all connected USB devices. This helper function provides a simplified interface for interacting with the plugin methods. It is recommended for most use cases unless more granular control is required. Each DeviceHandler object includes methods for connecting, disconnecting, writing to, and reading from a specific device.

Returns: Promise<DeviceHandler[]>


getDeviceConnections()

getDeviceConnections() => Promise<{ devices: DeviceInfo[]; }>

Returns all connected devices

Returns: Promise<{ devices: DeviceInfo[]; }>


openConnection(...)

openConnection(options: FullConnectionParams) => Promise<{ portKey: string; }>

Connect to a device using its deviceId

| Param | Type | Description | | ------------- | --------------------------------------------------------------------- | ------------------------------------------ | | options | FullConnectionParams | - Connection parameters including deviceId |

Returns: Promise<{ portKey: string; }>


getActivePorts()

getActivePorts() => Promise<{ ports: string[]; }>

Returns all active ports

Returns: Promise<{ ports: string[]; }>


endConnection(...)

endConnection(options: { key: string; }) => Promise<void>

Disconnect from a device using its assigned portKey

| Param | Type | Description | | ------------- | ----------------------------- | ------------------------------- | | options | { key: string; } | - Object containing the portKey |


endConnections(...)

endConnections(options?: { keys?: string[] | undefined; } | undefined) => Promise<void>

Disconnect from all devices or specified devices

| Param | Type | Description | | ------------- | --------------------------------- | --------------------------------------------------------------- | | options | { keys?: string[]; } | - Optional object containing an array of portKeys to disconnect |


write(...)

write(options: { key: string; message: string; noRead?: boolean }) => Promise<ReadResponse>

Write a message to a device using its assigned portKey and performs a quick read straight afterwards. If noRead is passed as true the read would be skipped.

| Param | Type | Description | | ------------- | ---------------------------------------------- | ---------------------------------------------------- | | options | { key: string; message: string; noRead?: boolean } | - Object containing the portKey and message to write |


read(...)

read(options: { key: string; }) => Promise<ReadResponse>

Read a message from a device using its assigned portKey

| Param | Type | Description | | ------------- | ----------------------------- | ------------------------------- | | options | { key: string; } | - Object containing the portKey |

Returns: Promise<ReadResponse>


Interfaces

DeviceHandler

Provides a simplified interface for handling a specific device

| Method | Type | Description | | -----------------| ---------------------------------------------------------- | --------------------------------- | | connect | (options?: ConnectionParams) => Promise | Connect to the device | | disconnect | () => Promise | Disconnect from the device | | write | (message: string) => Promise | Write a message to the device | | read | () => Promise | Read a message from the device |

DeviceInfo

Represents information about a connected device

| Prop | Type | Description | | ---------------- | ------------------- | --------------------------------- | | deviceKey | string | Unique identifier used internally | | deviceId | number | Numeric identifier for the device | | productId | number | Product ID of the device | | vendorId | number | Vendor ID of the device | | deviceName | string | Human-readable name of the device |

FullConnectionParams

Extends ConnectionParams to include deviceId

| Prop | Type | Description | | -------------- | ------------------- | -------------------------------- | | deviceId | number | Unique identifier for the device |

Type Aliases

ReadResponse

Represents the response from a read operation

{ data: string, bytesRead: number }