mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-03-26 04:46:35 +08:00
fix: 修复了确认对话框操作的变量在点击时被重置的bug
This commit is contained in:
@@ -258,6 +258,7 @@ impl AtxKeyExecutor {
|
||||
|
||||
/// Pulse Serial relay
|
||||
async fn pulse_serial(&self, duration: Duration) -> Result<()> {
|
||||
info!("Pulse serial relay on {} pin {}", self.config.device, self.config.pin);
|
||||
// Turn relay on
|
||||
self.send_serial_relay_command(true)?;
|
||||
|
||||
@@ -272,13 +273,19 @@ impl AtxKeyExecutor {
|
||||
|
||||
/// Send Serial relay command using cached handle
|
||||
fn send_serial_relay_command(&self, on: bool) -> Result<()> {
|
||||
// user config pin should be 1 for most LCUS modules (A0 01 01 A2)
|
||||
// if user set 0, it will send A0 00 01 A1 which might not work
|
||||
let channel = self.config.pin as u8;
|
||||
|
||||
// LCUS-Type Protocol
|
||||
// Frame: [StopByte(A0), Channel, State, Checksum]
|
||||
// Checksum = A0 + channel + state
|
||||
let state = if on { 1 } else { 0 };
|
||||
let checksum = 0xA0u8.wrapping_add(channel).wrapping_add(state);
|
||||
|
||||
// Example for Channel 1:
|
||||
// ON: A0 01 01 A2
|
||||
// OFF: A0 01 00 A1
|
||||
let cmd = [0xA0, channel, state, checksum];
|
||||
|
||||
let mut guard = self.serial_handle.lock().unwrap();
|
||||
|
||||
@@ -33,7 +33,7 @@ pub enum AtxDriverType {
|
||||
Gpio,
|
||||
/// USB HID relay module
|
||||
UsbRelay,
|
||||
/// Serial/COM port relay (LCUS type)
|
||||
/// Serial/COM port relay (taobao LCUS type)
|
||||
Serial,
|
||||
/// Disabled / Not configured
|
||||
None,
|
||||
|
||||
@@ -2641,6 +2641,7 @@ pub async fn atx_power(
|
||||
State(state): State<Arc<AppState>>,
|
||||
Json(req): Json<AtxPowerControlRequest>,
|
||||
) -> Result<Json<LoginResponse>> {
|
||||
tracing::info!("Received ATX power request: action={}", req.action);
|
||||
let atx_guard = state.atx.read().await;
|
||||
let atx = atx_guard
|
||||
.as_ref()
|
||||
|
||||
Reference in New Issue
Block a user