This plugin can be used for reading data from other device over the usb channel
npm install usb-serial-plugin
npx cap sync
connectedDevices()
openSerial(...)
closeSerial()
readSerial()
writeSerial(...)
addListener('log', ...)
addListener('connected', ...)
addListener('attached', ...)
addListener('detached', ...)
addListener('data', ...)
addListener('error', ...)
- Interfaces
connectedDevices() => Promise<{ devices: []; }>
Returns: Promise<{ devices: []; }>
openSerial(options: UsbSerialOptions) => Promise<void>
Param | Type |
---|---|
options |
UsbSerialOptions |
closeSerial() => Promise<void>
readSerial() => Promise<{ data: string; }>
Returns: Promise<{ data: string; }>
writeSerial(options: { data: string; }) => Promise<void>
Param | Type |
---|---|
options |
{ data: string; } |
addListener(eventName: 'log', listenerFunc: (data: { text: string; tag: string; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'log' |
listenerFunc |
(data: { text: string; tag: string; }) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener(eventName: 'connected', listenerFunc: (data: UsbSerialDevice) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'connected' |
listenerFunc |
(data: UsbSerialDevice) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener(eventName: 'attached', listenerFunc: (data: UsbSerialDevice) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'attached' |
listenerFunc |
(data: UsbSerialDevice) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener(eventName: 'detached', listenerFunc: (data: UsbSerialDevice) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'detached' |
listenerFunc |
(data: UsbSerialDevice) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener(eventName: 'data', listenerFunc: (data: { data: string; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'data' |
listenerFunc |
(data: { data: string; }) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener(eventName: 'error', listenerFunc: (data: { error: string; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'error' |
listenerFunc |
(data: { error: string; }) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Prop | Type |
---|---|
deviceId |
number |
portNum |
number |
baudRate |
number |
dataBits |
number |
stopBits |
number |
parity |
number |
dtr |
boolean |
rts |
boolean |
Prop | Type |
---|---|
remove |
() => Promise<void> |
Prop | Type |
---|---|
pid |
number |
vid |
number |
did |
number |