pub fn write_data_terminal_ready<R: Runtime>(
_app: AppHandle<R>,
serial: State<'_, SerialPort<R>>,
path: String,
level: bool,
) -> Result<(), Error>
Expand description
Sets the DTR (Data Terminal Ready) control signal
Controls the DTR signal line on the serial port. This signal indicates that the terminal (computer) is ready for communication.
§Arguments
_app
- The Tauri app handleserial
- The serial port statepath
- The path to the serial port (e.g., “COM1”, “/dev/ttyUSB0”)level
- The signal level (true for high, false for low)
§Returns
Ok(())
if the DTR signal was set successfully, or an Error
if it failed.
§Example
use tauri_plugin_serialplugin::commands::write_data_terminal_ready;
use tauri::{AppHandle, State};
#[tauri::command]
async fn control_dtr(
app: AppHandle<tauri::Wry>,
serial: State<'_, tauri_plugin_serialplugin::desktop_api::SerialPort<tauri::Wry>>
) -> Result<(), String> {
write_data_terminal_ready(app, serial, "COM1".to_string(), true)
.map_err(|e| e.to_string())
}
§JavaScript Equivalent
import { SerialPort } from "tauri-plugin-serialplugin-api";;
const port = new SerialPort({ path: "COM1" });
await port.open();
await port.writeDataTerminalReady(true);