API reference

Tauri commands

Every Tauri command of the plugin with its arguments, generated from src/commands.rs.

The #[tauri::command] functions in src/commands.rs, which the JS package calls with invoke('plugin:serialplugin|<name>', args). You normally use the SerialPort class instead; this list is for calling commands directly or from Rust (see Rust). Arguments are sent in camelCase; AppHandle and State parameters are injected by Tauri and not listed.

CommandDescription
available_portsLists all available serial ports on the system
managed_portsLists all currently managed serial ports
cancel_readCancels an in-flight poll read on a serial port (does not stop an active watch).
closeCloses a serial port
close_allCloses all open serial ports
force_closeForcefully closes a serial port
openOpens a serial port with the specified configuration
writeWrites string data to a serial port
write_binaryWrites binary data to a serial port
readReads string data from a serial port
read_binaryReads binary data from a serial port
capabilitiesReturns runtime capabilities (transport, platform, version) without window probing.
watch
unwatchStops a watch session by channel id.
watch_portsStreams available-port attach/detach events through a Tauri IPC channel.
unwatch_portsStops a port-list watch session by channel id.
set_baud_rateSets the baud rate for a serial port
set_data_bitsSets the number of data bits for a serial port
set_flow_controlSets the flow control mode for a serial port
set_paritySets the parity checking mode for a serial port
set_stop_bitsSets the number of stop bits for a serial port
set_timeoutSets the read timeout for a serial port
write_request_to_sendSets the RTS (Request To Send) control signal
write_data_terminal_readySets the DTR (Data Terminal Ready) control signal
read_clear_to_sendReads the CTS (Clear To Send) control signal state
read_data_set_readyReads the DSR (Data Set Ready) control signal state
read_ring_indicatorReads the RI (Ring Indicator) control signal state
read_carrier_detectReads the CD (Carrier Detect) control signal state
bytes_to_readGets the number of bytes available to read from the serial port
bytes_to_writeGets the number of bytes available to write to the serial port
clear_bufferClears the specified buffer of the serial port
set_breakSets the break condition on the serial port
clear_breakClears the break condition on the serial port
set_log_levelSets the global log level for the plugin
get_log_levelGets the current global log level
exchangeWrite and read-until-response (AT-style exchange).
cancel_exchangeCancel an in-flight exchange on a port.
atSend one AT command with native session defaults and FIFO queue.
at_phasesMulti-phase AT flow (e.g. CMGS) as one atomic queue job.
send_sms_pduBuilt-in CMGS recipe through the native transaction queue.
configure_at_sessionConfigure AT session defaults for native at on a port.
exchange_binaryBinary write + read-until-response (e.g. CMGS PDU).
enable_muxEnter GSM 07.10 CMUX mode on a physical port (desktop).
open_mux_channelOpen a virtual CMUX channel (returns composite path).
disable_muxTear down CMUX and close virtual channels.
ble_scanScan for Bluetooth LE devices advertising the Nordic UART Service.

Commands

available_ports

Lists all available serial ports on the system

invoke('plugin:serialplugin|available_ports', { singlePortPerDevice })
Argument (JS)Rust parameterType
singlePortPerDevicesingle_port_per_deviceOption<bool>

Returns HashMap<String, HashMap<String, String>>. Rust: async fn. Permission: serialplugin:allow-available-ports.

managed_ports

Lists all currently managed serial ports

invoke('plugin:serialplugin|managed_ports')

No arguments.

Returns Vec<String>. Rust: plain (sync) fn. Permission: serialplugin:allow-managed-ports.

cancel_read

Cancels an in-flight poll read on a serial port (does not stop an active watch).

invoke('plugin:serialplugin|cancel_read', { path })
Argument (JS)Rust parameterType
pathpathString

Returns (). Rust: async fn. Permission: serialplugin:allow-cancel-read.

close

Closes a serial port

invoke('plugin:serialplugin|close', { path })
Argument (JS)Rust parameterType
pathpathString

Returns (). Rust: async fn. Permission: serialplugin:allow-close.

close_all

Closes all open serial ports

invoke('plugin:serialplugin|close_all')

No arguments.

Returns (). Rust: async fn. Permission: serialplugin:allow-close-all.

force_close

Forcefully closes a serial port

invoke('plugin:serialplugin|force_close', { path })
Argument (JS)Rust parameterType
pathpathString

Returns (). Rust: async fn. Permission: serialplugin:allow-force-close.

open

Opens a serial port with the specified configuration

invoke('plugin:serialplugin|open', { path, baudRate, dataBits, flowControl, parity, stopBits, timeout, dtr, rts })
Argument (JS)Rust parameterType
pathpathString
baudRatebaud_rateu32
dataBitsdata_bitsOption<DataBits>
flowControlflow_controlOption<FlowControl>
parityparityOption<Parity>
stopBitsstop_bitsOption<StopBits>
timeouttimeoutOption<u64>
dtrdtrOption<bool>
rtsrtsOption<bool>

Returns String. Rust: async fn. Permission: serialplugin:allow-open.

write

Writes string data to a serial port

invoke('plugin:serialplugin|write', { path, value })
Argument (JS)Rust parameterType
pathpathString
valuevalueString

Returns usize. Rust: async fn. Permission: serialplugin:allow-write.

write_binary

Writes binary data to a serial port

invoke('plugin:serialplugin|write_binary', { path, value })
Argument (JS)Rust parameterType
pathpathString
valuevalueVec<u8>

Returns usize. Rust: async fn. Permission: serialplugin:allow-write-binary.

read

Reads string data from a serial port

invoke('plugin:serialplugin|read', { path, timeout, size })
Argument (JS)Rust parameterType
pathpathString
timeouttimeoutOption<u64>
sizesizeOption<usize>

Returns String. Rust: async fn. Permission: serialplugin:allow-read.

read_binary

Reads binary data from a serial port

invoke('plugin:serialplugin|read_binary', { path, timeout, size })
Argument (JS)Rust parameterType
pathpathString
timeouttimeoutOption<u64>
sizesizeOption<usize>

Returns Vec<u8>. Rust: async fn. Permission: serialplugin:allow-read-binary.

capabilities

Returns runtime capabilities (transport, platform, version) without window probing.

invoke('plugin:serialplugin|capabilities')

No arguments.

Returns Capabilities. Rust: plain (sync) fn. Permission: serialplugin:allow-capabilities.

watch

invoke('plugin:serialplugin|watch', { path, options, parser, channel })
Argument (JS)Rust parameterType
pathpathString
optionsoptionsWatchOptions
parserparserOption<serial_codec::framing::FramerConfig>
channelchannelChannel<SerialEvent>

Returns u32. Rust: async fn. Permission: serialplugin:allow-watch.

unwatch

Stops a watch session by channel id.

invoke('plugin:serialplugin|unwatch', { channelId })
Argument (JS)Rust parameterType
channelIdchannel_idu32

Returns (). Rust: async fn. Permission: serialplugin:allow-unwatch.

watch_ports

Streams available-port attach/detach events through a Tauri IPC channel.

invoke('plugin:serialplugin|watch_ports', { options, channel })
Argument (JS)Rust parameterType
optionsoptionsOption<crate::events::WatchPortsOptions>
channelchanneltauri::ipc::Channel<crate::events::PortListEvent>

Returns u32. Rust: async fn. Permission: serialplugin:allow-watch-ports.

unwatch_ports

Stops a port-list watch session by channel id.

invoke('plugin:serialplugin|unwatch_ports', { channelId })
Argument (JS)Rust parameterType
channelIdchannel_idu32

Returns (). Rust: async fn. Permission: serialplugin:allow-unwatch-ports.

set_baud_rate

Sets the baud rate for a serial port

invoke('plugin:serialplugin|set_baud_rate', { path, baudRate })
Argument (JS)Rust parameterType
pathpathString
baudRatebaud_rateu32

Returns (). Rust: async fn. Permission: serialplugin:allow-set-baud-rate.

set_data_bits

Sets the number of data bits for a serial port

invoke('plugin:serialplugin|set_data_bits', { path, dataBits })
Argument (JS)Rust parameterType
pathpathString
dataBitsdata_bitsDataBits

Returns (). Rust: async fn. Permission: serialplugin:allow-set-data-bits.

set_flow_control

Sets the flow control mode for a serial port

invoke('plugin:serialplugin|set_flow_control', { path, flowControl })
Argument (JS)Rust parameterType
pathpathString
flowControlflow_controlFlowControl

Returns (). Rust: async fn. Permission: serialplugin:allow-set-flow-control.

set_parity

Sets the parity checking mode for a serial port

invoke('plugin:serialplugin|set_parity', { path, parity })
Argument (JS)Rust parameterType
pathpathString
parityparityParity

Returns (). Rust: async fn. Permission: serialplugin:allow-set-parity.

set_stop_bits

Sets the number of stop bits for a serial port

invoke('plugin:serialplugin|set_stop_bits', { path, stopBits })
Argument (JS)Rust parameterType
pathpathString
stopBitsstop_bitsStopBits

Returns (). Rust: async fn. Permission: serialplugin:allow-set-stop-bits.

set_timeout

Sets the read timeout for a serial port

invoke('plugin:serialplugin|set_timeout', { path, timeout })
Argument (JS)Rust parameterType
pathpathString
timeouttimeoutu64

Returns (). Rust: async fn. Permission: serialplugin:allow-set-timeout.

write_request_to_send

Sets the RTS (Request To Send) control signal

invoke('plugin:serialplugin|write_request_to_send', { path, level })
Argument (JS)Rust parameterType
pathpathString
levellevelbool

Returns (). Rust: async fn. Permission: serialplugin:allow-write-request-to-send.

write_data_terminal_ready

Sets the DTR (Data Terminal Ready) control signal

invoke('plugin:serialplugin|write_data_terminal_ready', { path, level })
Argument (JS)Rust parameterType
pathpathString
levellevelbool

Returns (). Rust: async fn. Permission: serialplugin:allow-write-data-terminal-ready.

read_clear_to_send

Reads the CTS (Clear To Send) control signal state

invoke('plugin:serialplugin|read_clear_to_send', { path })
Argument (JS)Rust parameterType
pathpathString

Returns bool. Rust: async fn. Permission: serialplugin:allow-read-clear-to-send.

read_data_set_ready

Reads the DSR (Data Set Ready) control signal state

invoke('plugin:serialplugin|read_data_set_ready', { path })
Argument (JS)Rust parameterType
pathpathString

Returns bool. Rust: async fn. Permission: serialplugin:allow-read-data-set-ready.

read_ring_indicator

Reads the RI (Ring Indicator) control signal state

invoke('plugin:serialplugin|read_ring_indicator', { path })
Argument (JS)Rust parameterType
pathpathString

Returns bool. Rust: async fn. Permission: serialplugin:allow-read-ring-indicator.

read_carrier_detect

Reads the CD (Carrier Detect) control signal state

invoke('plugin:serialplugin|read_carrier_detect', { path })
Argument (JS)Rust parameterType
pathpathString

Returns bool. Rust: async fn. Permission: serialplugin:allow-read-carrier-detect.

bytes_to_read

Gets the number of bytes available to read from the serial port

invoke('plugin:serialplugin|bytes_to_read', { path })
Argument (JS)Rust parameterType
pathpathString

Returns u32. Rust: async fn. Permission: serialplugin:allow-bytes-to-read.

bytes_to_write

Gets the number of bytes available to write to the serial port

invoke('plugin:serialplugin|bytes_to_write', { path })
Argument (JS)Rust parameterType
pathpathString

Returns u32. Rust: async fn. Permission: serialplugin:allow-bytes-to-write.

clear_buffer

Clears the specified buffer of the serial port

invoke('plugin:serialplugin|clear_buffer', { path, bufferType })
Argument (JS)Rust parameterType
pathpathString
bufferTypebuffer_typeClearBuffer

Returns (). Rust: async fn. Permission: serialplugin:allow-clear-buffer.

set_break

Sets the break condition on the serial port

invoke('plugin:serialplugin|set_break', { path })
Argument (JS)Rust parameterType
pathpathString

Returns (). Rust: async fn. Permission: serialplugin:allow-set-break.

clear_break

Clears the break condition on the serial port

invoke('plugin:serialplugin|clear_break', { path })
Argument (JS)Rust parameterType
pathpathString

Returns (). Rust: async fn. Permission: serialplugin:allow-clear-break.

set_log_level

Sets the global log level for the plugin

invoke('plugin:serialplugin|set_log_level', { level })
Argument (JS)Rust parameterType
levellevelcrate::state::LogLevel

Returns (). Rust: plain (sync) fn. Permission: serialplugin:allow-set-log-level.

get_log_level

Gets the current global log level

invoke('plugin:serialplugin|get_log_level')

No arguments.

Returns crate::state::LogLevel. Rust: plain (sync) fn. Permission: serialplugin:allow-get-log-level.

exchange

Write and read-until-response (AT-style exchange).

invoke('plugin:serialplugin|exchange', { path, value, options })
Argument (JS)Rust parameterType
pathpathString
valuevalueString
optionsoptionsOption<ExchangeOptions>

Returns crate::at::parse::ExchangeResponse. Rust: async fn. Permission: serialplugin:allow-exchange.

cancel_exchange

Cancel an in-flight exchange on a port.

invoke('plugin:serialplugin|cancel_exchange', { path })
Argument (JS)Rust parameterType
pathpathString

Returns (). Rust: async fn. Permission: serialplugin:allow-cancel-exchange.

at

Send one AT command with native session defaults and FIFO queue.

invoke('plugin:serialplugin|at', { path, command, options })
Argument (JS)Rust parameterType
pathpathString
commandcommandString
optionsoptionsOption<crate::at::session::AtCommandOptions>

Returns crate::at::parse::AtCommandResult. Rust: async fn. Permission: serialplugin:allow-at.

at_phases

Multi-phase AT flow (e.g. CMGS) as one atomic queue job.

invoke('plugin:serialplugin|at_phases', { path, phases })
Argument (JS)Rust parameterType
pathpathString
phasesphasesVec<crate::at::session::AtPhase>

Returns Vec<crate::at::parse::AtCommandResult>. Rust: async fn. Permission: serialplugin:allow-at-phases.

send_sms_pdu

Built-in CMGS recipe through the native transaction queue.

invoke('plugin:serialplugin|send_sms_pdu', { path, length, pdu, options })
Argument (JS)Rust parameterType
pathpathString
lengthlengthu32
pdupduVec<u8>
optionsoptionsOption<crate::at::session::SendSmsPduOptions>

Returns Vec<crate::at::parse::AtCommandResult>. Rust: async fn. Permission: serialplugin:allow-send-sms-pdu.

configure_at_session

Configure AT session defaults for native at on a port.

invoke('plugin:serialplugin|configure_at_session', { path, session })
Argument (JS)Rust parameterType
pathpathString
sessionsessioncrate::at::session::AtSessionConfig

Returns (). Rust: async fn. Permission: serialplugin:allow-configure-at-session.

exchange_binary

Binary write + read-until-response (e.g. CMGS PDU).

invoke('plugin:serialplugin|exchange_binary', { path, value, options })
Argument (JS)Rust parameterType
pathpathString
valuevalueVec<u8>
optionsoptionsOption<crate::events::ExchangeOptions>

Returns crate::at::parse::ExchangeResponse. Rust: async fn. Permission: serialplugin:allow-exchange-binary.

enable_mux

Enter GSM 07.10 CMUX mode on a physical port (desktop).

invoke('plugin:serialplugin|enable_mux', { path, options })
Argument (JS)Rust parameterType
pathpathString
optionsoptionsOption<EnableMuxOptions>

Returns (). Rust: async fn. Permission: serialplugin:allow-enable-mux.

open_mux_channel

Open a virtual CMUX channel (returns composite path).

invoke('plugin:serialplugin|open_mux_channel', { path, dlci })
Argument (JS)Rust parameterType
pathpathString
dlcidlciu8

Returns String. Rust: async fn. Permission: serialplugin:allow-open-mux-channel.

disable_mux

Tear down CMUX and close virtual channels.

invoke('plugin:serialplugin|disable_mux', { path })
Argument (JS)Rust parameterType
pathpathString

Returns (). Rust: async fn. Permission: serialplugin:allow-disable-mux.

ble_scan

Scan for Bluetooth LE devices advertising the Nordic UART Service. Returns ble://<id> paths (open them like any port). Needs the ble feature.

invoke('plugin:serialplugin|ble_scan', { timeoutMs })
Argument (JS)Rust parameterType
timeoutMstimeout_msOption<u64>

Returns HashMap<String, HashMap<String, String>>. Rust: async fn. Permission: serialplugin:allow-ble-scan.