pub fn read_ring_indicator<R: Runtime>(
_app: AppHandle<R>,
serial: State<'_, SerialPort<R>>,
path: String,
) -> Result<bool, Error>
Expand description
Reads the RI (Ring Indicator) control signal state
Reads the current state of the RI signal line. This signal indicates that an incoming call is being received (commonly used with modems).
§Arguments
_app
- The Tauri app handleserial
- The serial port statepath
- The path to the serial port (e.g., “COM1”, “/dev/ttyUSB0”)
§Returns
The RI signal state (true for high, false for low), or an Error
if it failed.
§Example
use tauri_plugin_serialplugin::commands::read_ring_indicator;
use tauri::{AppHandle, State};
#[tauri::command]
async fn check_ring(
app: AppHandle<tauri::Wry>,
serial: State<'_, tauri_plugin_serialplugin::desktop_api::SerialPort<tauri::Wry>>
) -> Result<(), String> {
let ri_state = read_ring_indicator(app, serial, "COM1".to_string())
.map_err(|e| e.to_string())?;
println!("Ring indicator is: {}", if ri_state { "active" } else { "inactive" });
Ok(())
}
§JavaScript Equivalent
import { SerialPort } from "tauri-plugin-serialplugin-api";;
const port = new SerialPort({ path: "COM1" });
await port.open();
const riState = await port.readRingIndicator();
console.log("Ring indicator is:", riState ? "active" : "inactive");