mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
refactor(ssh,video,firmware): deduplicate Radxa SSH, harden DMA-BUF bounds & split g29_crsf firmware
This commit is contained in:
1 parent
e7218ebac1
commit
dffa6e2de2
9 files changed
+2039
-2014
No files matched your search
@@ -6,6 +6,7 @@ pub mod vr_menu;
|
||||
mod xr_session;
|
||||
|
||||
pub use control_handle::EngineControlHandle;
|
||||
pub use radxa_ssh::apply_radxa_wifi_channel_ssh;
|
||||
pub use types::{
|
||||
DvrConfig, EngineSharedState, LiveOpticalParams, RetrySlot, RuntimeMonitor, SubsystemStatus,
|
||||
};
|
||||
|
||||
+39
-31
@@ -4,6 +4,41 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
|
||||
/// Exécute de façon synchrone la mise à jour du canal 5.8 GHz sur la Radxa Zero 3W via SSH sécurisé.
|
||||
pub fn apply_radxa_wifi_channel_ssh(ch: u16, ip: std::net::IpAddr) -> std::result::Result<(), String> {
|
||||
// Vérifie qu'au moins la mise à jour config ou `iw` réussit (exit != 0 si tout échoue)
|
||||
let remote_cmd = format!(
|
||||
"ok=0; \
|
||||
if [ -f /etc/wifibroadcast.cfg ]; then sed -i 's/^wifi_channel.*/wifi_channel = {ch}/' /etc/wifibroadcast.cfg && ok=1; fi; \
|
||||
for iface in wlan0 wlx*; do if [ -d \"/sys/class/net/$iface\" ]; then iw dev \"$iface\" set channel {ch} HT20 2>/dev/null && ok=1; fi; done; \
|
||||
[ \"$ok\" -eq 1 ]"
|
||||
);
|
||||
|
||||
let res = std::process::Command::new("ssh")
|
||||
.args([
|
||||
"-o",
|
||||
"BatchMode=yes",
|
||||
"-o",
|
||||
"ConnectTimeout=2",
|
||||
"-o",
|
||||
"StrictHostKeyChecking=accept-new",
|
||||
"--",
|
||||
&format!("root@{}", ip),
|
||||
&remote_cmd,
|
||||
])
|
||||
.output();
|
||||
|
||||
match res {
|
||||
Ok(out) if out.status.success() => Ok(()),
|
||||
Ok(out) => Err(format!(
|
||||
"exit={}: {}",
|
||||
out.status,
|
||||
String::from_utf8_lossy(&out.stderr).trim()
|
||||
)),
|
||||
Err(e) => Err(format!("erreur exécution ssh: {}", e)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Lance en arrière-plan la mise à jour du canal 5.8 GHz sur la Radxa Zero 3W via SSH sécurisé.
|
||||
/// Protégé par un verrou atomique `ssh_busy` pour empêcher les exécutions concurrentes.
|
||||
pub fn spawn_apply_radxa_channel(
|
||||
@@ -24,46 +59,19 @@ pub fn spawn_apply_radxa_channel(
|
||||
};
|
||||
|
||||
menu_ref.lock().set_feedback("ENVOI CANAL SSH...", false);
|
||||
// Vérifie qu'au moins la mise à jour config ou `iw` réussit (exit != 0 si tout échoue)
|
||||
let remote_cmd = format!(
|
||||
"ok=0; \
|
||||
if [ -f /etc/wifibroadcast.cfg ]; then sed -i 's/^wifi_channel.*/wifi_channel = {ch}/' /etc/wifibroadcast.cfg && ok=1; fi; \
|
||||
for iface in wlan0 wlx*; do if [ -d \"/sys/class/net/$iface\" ]; then iw dev \"$iface\" set channel {ch} HT20 2>/dev/null && ok=1; fi; done; \
|
||||
[ \"$ok\" -eq 1 ]"
|
||||
);
|
||||
|
||||
thread::spawn(move || {
|
||||
let res = std::process::Command::new("ssh")
|
||||
.args([
|
||||
"-o",
|
||||
"BatchMode=yes",
|
||||
"-o",
|
||||
"ConnectTimeout=2",
|
||||
"-o",
|
||||
"StrictHostKeyChecking=accept-new",
|
||||
"--",
|
||||
&format!("root@{}", ip),
|
||||
&remote_cmd,
|
||||
])
|
||||
.output();
|
||||
let res = apply_radxa_wifi_channel_ssh(ch, ip);
|
||||
ssh_busy.store(false, Ordering::Release);
|
||||
match res {
|
||||
Ok(out) if out.status.success() => {
|
||||
Ok(()) => {
|
||||
log::info!("[Menu VR] Canal 5.8GHz {} appliqué sur Radxa {}", ch, ip);
|
||||
menu_ref.lock().set_feedback("CANAL RADXA OK", false);
|
||||
}
|
||||
Ok(out) => {
|
||||
log::warn!(
|
||||
"[Menu VR] Échec SSH canal Radxa (exit={}): {}",
|
||||
out.status,
|
||||
String::from_utf8_lossy(&out.stderr).trim()
|
||||
);
|
||||
Err(err_msg) => {
|
||||
log::warn!("[Menu VR] Échec SSH canal Radxa ({})", err_msg);
|
||||
menu_ref.lock().set_feedback("ECHEC SSH RADXA", true);
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("[Menu VR] Erreur SSH Radxa : {}", e);
|
||||
menu_ref.lock().set_feedback("ERREUR SSH", true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
+4
-27
@@ -484,40 +484,17 @@ impl SteamFrameGpuiApp {
|
||||
ch,
|
||||
ip
|
||||
);
|
||||
let remote_cmd = format!(
|
||||
"ok=0; \
|
||||
if [ -f /etc/wifibroadcast.cfg ]; then sed -i 's/^wifi_channel.*/wifi_channel = {ch}/' /etc/wifibroadcast.cfg && ok=1; fi; \
|
||||
for iface in wlan0 wlx*; do if [ -d \"/sys/class/net/$iface\" ]; then iw dev \"$iface\" set channel {ch} HT20 2>/dev/null && ok=1; fi; done; \
|
||||
[ \"$ok\" -eq 1 ]"
|
||||
);
|
||||
let busy = Arc::clone(&self.subprocess_busy);
|
||||
std::thread::spawn(move || {
|
||||
let res = Command::new("ssh")
|
||||
.args([
|
||||
"-o",
|
||||
"BatchMode=yes",
|
||||
"-o",
|
||||
"ConnectTimeout=2",
|
||||
"-o",
|
||||
"StrictHostKeyChecking=accept-new",
|
||||
"--",
|
||||
&format!("root@{}", ip),
|
||||
&remote_cmd,
|
||||
])
|
||||
.output();
|
||||
let res = crate::engine::apply_radxa_wifi_channel_ssh(ch, ip);
|
||||
busy.store(false, Ordering::Release);
|
||||
match res {
|
||||
Ok(out) if out.status.success() => {
|
||||
Ok(()) => {
|
||||
log::info!("[Radxa Zero 3W] Canal 5.8GHz configuré avec succès sur {}", ip);
|
||||
}
|
||||
Ok(out) => {
|
||||
log::warn!(
|
||||
"[Radxa Zero 3W] SSH retour exit={} : {}",
|
||||
out.status,
|
||||
String::from_utf8_lossy(&out.stderr).trim()
|
||||
);
|
||||
Err(err_msg) => {
|
||||
log::warn!("[Radxa Zero 3W] Échec commande SSH ({})", err_msg);
|
||||
}
|
||||
Err(e) => log::error!("[Radxa Zero 3W] Échec commande SSH : {}", e),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+18
-4
@@ -667,12 +667,24 @@ fn extract_dmabuf_frame(
|
||||
}
|
||||
};
|
||||
|
||||
let min_needed = uv_offset as usize + (uv_stride as usize) * (info.height() as usize / 2);
|
||||
let total_size = mem.size().max(min_needed);
|
||||
let min_y_bytes = (y_stride as usize).saturating_mul(info.height() as usize);
|
||||
let min_uv_bytes = (uv_stride as usize).saturating_mul(info.height() as usize / 2);
|
||||
let min_needed = (uv_offset as usize).saturating_add(min_uv_bytes);
|
||||
let mem_size = mem.size();
|
||||
|
||||
// Garde de linéarité et de bornes : rejeter vers le repli CPU si le DMA-BUF est plus petit
|
||||
// que le plan NV12 linéaire attendu (ex. buffer compressé/tuilé ou métadonnées incohérentes).
|
||||
if y_stride < info.width()
|
||||
|| uv_stride < info.width()
|
||||
|| (uv_offset as usize) < min_y_bytes
|
||||
|| mem_size < min_needed
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(DmaBufFrame {
|
||||
fd,
|
||||
size: total_size,
|
||||
size: mem_size,
|
||||
width: info.width(),
|
||||
height: info.height(),
|
||||
y_stride,
|
||||
@@ -1015,7 +1027,9 @@ fn supervisor_loop(
|
||||
}
|
||||
}
|
||||
|
||||
let p = pipeline.as_ref().unwrap();
|
||||
let Some(p) = pipeline.as_ref() else {
|
||||
continue;
|
||||
};
|
||||
let mut needs_rebuild = false;
|
||||
|
||||
if let Some(bus) = p.bus() {
|
||||
|
||||
Reference in new issue
Block a user