mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
fix(safety): harden dual-core atomics, UDP peer filtering, TOCTOU, and CRC-8 UART frames
This commit is contained in:
1 parent
426ab7c7d6
commit
c0bad51d3b
9 files changed
+232
-72
No files matched your search
@@ -242,17 +242,31 @@ volatile uint8_t extEmbrayagePct = 0;
|
|||||||
volatile int8_t extVolantPct = 0;
|
volatile int8_t extVolantPct = 0;
|
||||||
volatile uint32_t dernierPaquetRC_ms = 0;
|
volatile uint32_t dernierPaquetRC_ms = 0;
|
||||||
|
|
||||||
|
static inline uint16_t crsfChannelLoad(uint8_t idx) {
|
||||||
|
return __atomic_load_n(&crsf_channels[idx], __ATOMIC_RELAXED);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void crsfChannelStore(uint8_t idx, uint16_t val) {
|
||||||
|
__atomic_store_n(&crsf_channels[idx], val, __ATOMIC_RELAXED);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool estActuellementArme() {
|
static inline bool estActuellementArme() {
|
||||||
return (sourceActive == SRC_EXT) ? extArme : estArme;
|
uint8_t src = __atomic_load_n(&sourceActive, __ATOMIC_ACQUIRE);
|
||||||
|
return (src == SRC_EXT)
|
||||||
|
? __atomic_load_n(&extArme, __ATOMIC_ACQUIRE)
|
||||||
|
: __atomic_load_n(&estArme, __ATOMIC_ACQUIRE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int8_t rapportActuel() {
|
static inline int8_t rapportActuel() {
|
||||||
return (sourceActive == SRC_EXT) ? extRapport : rapportEngage;
|
uint8_t src = __atomic_load_n(&sourceActive, __ATOMIC_ACQUIRE);
|
||||||
|
return (src == SRC_EXT)
|
||||||
|
? __atomic_load_n(&extRapport, __ATOMIC_ACQUIRE)
|
||||||
|
: __atomic_load_n(&rapportEngage, __ATOMIC_ACQUIRE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void assignerCanalCRSF(uint8_t numeroCh, uint16_t valeur11bits) {
|
static inline void assignerCanalCRSF(uint8_t numeroCh, uint16_t valeur11bits) {
|
||||||
if (numeroCh >= 1 && numeroCh <= 16 && numeroCh != CANAL_ARM) {
|
if (numeroCh >= 1 && numeroCh <= 16 && numeroCh != CANAL_ARM) {
|
||||||
crsf_channels[numeroCh - 1] = valeur11bits;
|
crsfChannelStore(numeroCh - 1, valeur11bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,9 +280,9 @@ void reinitialiserCanauxCRSF() {
|
|||||||
if (htActif && (i == (CANAL_HT_PAN - 1) || i == (CANAL_HT_TILT - 1) || i == (CANAL_HT_ROLL - 1))) {
|
if (htActif && (i == (CANAL_HT_PAN - 1) || i == (CANAL_HT_TILT - 1) || i == (CANAL_HT_ROLL - 1))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
crsf_channels[i] = CRSF_VAL_MID;
|
crsfChannelStore((uint8_t)i, CRSF_VAL_MID);
|
||||||
}
|
}
|
||||||
crsf_channels[CANAL_ARM - 1] = CRSF_VAL_MIN; // Toujours désarmé par défaut
|
crsfChannelStore(CANAL_ARM - 1, CRSF_VAL_MIN); // Toujours désarmé par défaut
|
||||||
}
|
}
|
||||||
|
|
||||||
void reinitialiserConfigurationDefaut() {
|
void reinitialiserConfigurationDefaut() {
|
||||||
@@ -293,7 +307,10 @@ void reinitialiserConfigurationDefaut() {
|
|||||||
|
|
||||||
void sauvegarderConfiguration() {
|
void sauvegarderConfiguration() {
|
||||||
ConfigG29 cfgActuelle;
|
ConfigG29 cfgActuelle;
|
||||||
|
// Geler brièvement le Cœur 1 pour garantir un instantané cohérent de configSysteme.
|
||||||
|
rp2040.idleOtherCore();
|
||||||
memcpy(&cfgActuelle, (const void*)&configSysteme, sizeof(ConfigG29));
|
memcpy(&cfgActuelle, (const void*)&configSysteme, sizeof(ConfigG29));
|
||||||
|
rp2040.resumeOtherCore();
|
||||||
|
|
||||||
ConfigG29 cfgStockee;
|
ConfigG29 cfgStockee;
|
||||||
EEPROM.get(0, cfgStockee);
|
EEPROM.get(0, cfgStockee);
|
||||||
@@ -553,13 +570,32 @@ void traiterLigneSerie(char* commande) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validation CRC-8 DVB-S2 (*XX) obligatoire sur toutes les trames $... (anti-corruption UART)
|
||||||
|
if (commande[0] == '$') {
|
||||||
|
char* star = strrchr(commande, '*');
|
||||||
|
if (!star || strlen(star + 1) != 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
char* endPtr = nullptr;
|
||||||
|
unsigned long crcRecu = strtoul(star + 1, &endPtr, 16);
|
||||||
|
if (endPtr != star + 3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
size_t bodyLen = (size_t)(star - commande);
|
||||||
|
uint8_t crcCalc = calculerCrc8Crsf((const uint8_t*)commande, bodyLen);
|
||||||
|
if ((uint8_t)crcRecu != crcCalc) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*star = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
// Injection Head-Tracking depuis SteamFrame FPV : $HT,<pan>,<tilt>,<roll> (172..1811)
|
// Injection Head-Tracking depuis SteamFrame FPV : $HT,<pan>,<tilt>,<roll> (172..1811)
|
||||||
if (strncmp(commande, "$HT,", 4) == 0) {
|
if (strncmp(commande, "$HT,", 4) == 0) {
|
||||||
int pan = CRSF_VAL_MID, tilt = CRSF_VAL_MID, roll = CRSF_VAL_MID;
|
int pan = CRSF_VAL_MID, tilt = CRSF_VAL_MID, roll = CRSF_VAL_MID;
|
||||||
if (sscanf(commande + 4, "%d,%d,%d", &pan, &tilt, &roll) == 3) {
|
if (sscanf(commande + 4, "%d,%d,%d", &pan, &tilt, &roll) == 3) {
|
||||||
crsf_channels[CANAL_HT_PAN - 1] = (uint16_t)constrain(pan, CRSF_VAL_MIN, CRSF_VAL_MAX);
|
crsfChannelStore(CANAL_HT_PAN - 1, (uint16_t)constrain(pan, CRSF_VAL_MIN, CRSF_VAL_MAX));
|
||||||
crsf_channels[CANAL_HT_TILT - 1] = (uint16_t)constrain(tilt, CRSF_VAL_MIN, CRSF_VAL_MAX);
|
crsfChannelStore(CANAL_HT_TILT - 1, (uint16_t)constrain(tilt, CRSF_VAL_MIN, CRSF_VAL_MAX));
|
||||||
crsf_channels[CANAL_HT_ROLL - 1] = (uint16_t)constrain(roll, CRSF_VAL_MIN, CRSF_VAL_MAX);
|
crsfChannelStore(CANAL_HT_ROLL - 1, (uint16_t)constrain(roll, CRSF_VAL_MIN, CRSF_VAL_MAX));
|
||||||
dernierPaquetHT_ms = millis();
|
dernierPaquetHT_ms = millis();
|
||||||
htActif = true;
|
htActif = true;
|
||||||
}
|
}
|
||||||
@@ -715,7 +751,7 @@ void traiterLigneSerie(char* commande) {
|
|||||||
assignerCanalCRSF(configSysteme.accel, vAccel);
|
assignerCanalCRSF(configSysteme.accel, vAccel);
|
||||||
assignerCanalCRSF(configSysteme.frein, vBrake);
|
assignerCanalCRSF(configSysteme.frein, vBrake);
|
||||||
assignerCanalCRSF(configSysteme.embrayage, vClutch);
|
assignerCanalCRSF(configSysteme.embrayage, vClutch);
|
||||||
crsf_channels[CANAL_ARM - 1] = extArme ? CRSF_VAL_MAX : CRSF_VAL_MIN;
|
crsfChannelStore(CANAL_ARM - 1, extArme ? CRSF_VAL_MAX : CRSF_VAL_MIN);
|
||||||
|
|
||||||
dernierPaquetRC_ms = millis();
|
dernierPaquetRC_ms = millis();
|
||||||
if (!extRcActif) {
|
if (!extRcActif) {
|
||||||
@@ -809,7 +845,7 @@ void __not_in_flash_func(envoyer_paquet_crsf)(bool neutre) {
|
|||||||
uint16_t ch[16];
|
uint16_t ch[16];
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
ch[i] = neutre ? CRSF_VAL_MID : crsf_channels[i];
|
ch[i] = neutre ? CRSF_VAL_MID : crsfChannelLoad((uint8_t)i);
|
||||||
}
|
}
|
||||||
if (neutre) ch[CANAL_ARM - 1] = CRSF_VAL_MIN; // Failsafe : toujours désarmé
|
if (neutre) ch[CANAL_ARM - 1] = CRSF_VAL_MIN; // Failsafe : toujours désarmé
|
||||||
|
|
||||||
@@ -1111,10 +1147,10 @@ void gererSortieCockpit() {
|
|||||||
int steer = (sourceActive == SRC_EXT)
|
int steer = (sourceActive == SRC_EXT)
|
||||||
? (int)extVolantPct
|
? (int)extVolantPct
|
||||||
: (int)constrain(((float)dernierVolantCentre / (float)dMax) * 100.0f, -100.0f, 100.0f);
|
: (int)constrain(((float)dernierVolantCentre / (float)dMax) * 100.0f, -100.0f, 100.0f);
|
||||||
uint16_t ch1 = failsafeActif ? CRSF_VAL_MID : crsf_channels[configSysteme.volant - 1];
|
uint16_t ch1 = failsafeActif ? CRSF_VAL_MID : crsfChannelLoad(configSysteme.volant - 1);
|
||||||
uint16_t ch2 = failsafeActif ? CRSF_VAL_MID : crsf_channels[configSysteme.accel - 1];
|
uint16_t ch2 = failsafeActif ? CRSF_VAL_MID : crsfChannelLoad(configSysteme.accel - 1);
|
||||||
uint16_t ch3 = failsafeActif ? CRSF_VAL_MID : crsf_channels[configSysteme.frein - 1];
|
uint16_t ch3 = failsafeActif ? CRSF_VAL_MID : crsfChannelLoad(configSysteme.frein - 1);
|
||||||
uint16_t ch4 = failsafeActif ? CRSF_VAL_MID : crsf_channels[configSysteme.embrayage - 1];
|
uint16_t ch4 = failsafeActif ? CRSF_VAL_MID : crsfChannelLoad(configSysteme.embrayage - 1);
|
||||||
const char* srcStr = (sourceActive == SRC_EXT) ? "EXT" : "G29";
|
const char* srcStr = (sourceActive == SRC_EXT) ? "EXT" : "G29";
|
||||||
char bufEtat[176];
|
char bufEtat[176];
|
||||||
snprintf(bufEtat, sizeof(bufEtat),
|
snprintf(bufEtat, sizeof(bufEtat),
|
||||||
@@ -1140,9 +1176,9 @@ void gererSortieCockpit() {
|
|||||||
void gererTimeoutHeadTracking() {
|
void gererTimeoutHeadTracking() {
|
||||||
if (htActif && (millis() - dernierPaquetHT_ms > TIMEOUT_HT_MS)) {
|
if (htActif && (millis() - dernierPaquetHT_ms > TIMEOUT_HT_MS)) {
|
||||||
htActif = false;
|
htActif = false;
|
||||||
crsf_channels[CANAL_HT_PAN - 1] = CRSF_VAL_MID;
|
crsfChannelStore(CANAL_HT_PAN - 1, CRSF_VAL_MID);
|
||||||
crsf_channels[CANAL_HT_TILT - 1] = CRSF_VAL_MID;
|
crsfChannelStore(CANAL_HT_TILT - 1, CRSF_VAL_MID);
|
||||||
crsf_channels[CANAL_HT_ROLL - 1] = CRSF_VAL_MID;
|
crsfChannelStore(CANAL_HT_ROLL - 1, CRSF_VAL_MID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1953,7 +1989,7 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i
|
|||||||
assignerCanalCRSF(configSysteme.accel, vAccel);
|
assignerCanalCRSF(configSysteme.accel, vAccel);
|
||||||
assignerCanalCRSF(configSysteme.frein, vFrein);
|
assignerCanalCRSF(configSysteme.frein, vFrein);
|
||||||
assignerCanalCRSF(configSysteme.embrayage, vEmbrayage);
|
assignerCanalCRSF(configSysteme.embrayage, vEmbrayage);
|
||||||
crsf_channels[CANAL_ARM - 1] = estArme ? CRSF_VAL_MAX : CRSF_VAL_MIN;
|
crsfChannelStore(CANAL_ARM - 1, __atomic_load_n(&estArme, __ATOMIC_ACQUIRE) ? CRSF_VAL_MAX : CRSF_VAL_MIN);
|
||||||
|
|
||||||
// Horodatage APRÈS l'écriture des canaux : à la sortie d'un failsafe, le cœur 0
|
// Horodatage APRÈS l'écriture des canaux : à la sortie d'un failsafe, le cœur 0
|
||||||
// ne peut pas renvoyer d'anciennes valeurs (d'avant la coupure) pendant un paquet.
|
// ne peut pas renvoyer d'anciennes valeurs (d'avant la coupure) pendant un paquet.
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import time
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
BAUD_RATE = termios.B460800
|
BAUD_RATE = termios.B460800
|
||||||
|
BIND_IP = os.environ.get("STEAMFRAME_BIND_IP", "192.168.1.1")
|
||||||
CASQUE_IP = os.environ.get("STEAMFRAME_CASQUE_IP", "192.168.1.10")
|
CASQUE_IP = os.environ.get("STEAMFRAME_CASQUE_IP", "192.168.1.10")
|
||||||
UDP_PORT = int(os.environ.get("STEAMFRAME_G29_PORT", "14552"))
|
UDP_PORT = int(os.environ.get("STEAMFRAME_G29_PORT", "14552"))
|
||||||
SERIAL_CANDIDATES = (
|
SERIAL_CANDIDATES = (
|
||||||
@@ -58,9 +59,22 @@ def find_serial_device() -> Optional[str]:
|
|||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
sock.bind(("0.0.0.0", UDP_PORT))
|
try:
|
||||||
|
sock.bind((BIND_IP, UDP_PORT))
|
||||||
|
bound_ip = BIND_IP
|
||||||
|
except OSError as exc:
|
||||||
|
print(
|
||||||
|
f"[radxa_g29_relay] Bind {BIND_IP}:{UDP_PORT} impossible ({exc}), fallback 0.0.0.0",
|
||||||
|
file=sys.stderr,
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
|
sock.bind(("0.0.0.0", UDP_PORT))
|
||||||
|
bound_ip = "0.0.0.0"
|
||||||
sock.setblocking(False)
|
sock.setblocking(False)
|
||||||
print(f"[radxa_g29_relay] UDP :0.0.0.0:{UDP_PORT} <-> {CASQUE_IP}:{UDP_PORT}", flush=True)
|
print(
|
||||||
|
f"[radxa_g29_relay] UDP {bound_ip}:{UDP_PORT} <-> {CASQUE_IP}:{UDP_PORT} (filtre IP actif)",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
|
|
||||||
serial_fd: Optional[int] = None
|
serial_fd: Optional[int] = None
|
||||||
serial_buf = bytearray()
|
serial_buf = bytearray()
|
||||||
@@ -97,6 +111,8 @@ def main() -> None:
|
|||||||
if sock.fileno() in readable:
|
if sock.fileno() in readable:
|
||||||
try:
|
try:
|
||||||
data, addr = sock.recvfrom(512)
|
data, addr = sock.recvfrom(512)
|
||||||
|
if addr[0] not in (CASQUE_IP, "127.0.0.1"):
|
||||||
|
continue
|
||||||
last_casque_addr = (addr[0], UDP_PORT)
|
last_casque_addr = (addr[0], UDP_PORT)
|
||||||
if data:
|
if data:
|
||||||
os.write(serial_fd, data)
|
os.write(serial_fd, data)
|
||||||
|
|||||||
+26
-16
@@ -448,20 +448,20 @@ pub fn brake_to_crsf(brake_norm: f32, deadzone: f32) -> (u8, u16) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn encode_src_command(source: ControlSource) -> String {
|
pub fn encode_src_command(source: ControlSource) -> String {
|
||||||
format!("$SRC,{}\n", source.wire_tag())
|
crate::nomad_elrs::NomadHeadTracker::append_nmea_crc8(&format!("$SRC,{}", source.wire_tag()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn encode_gears_command(limits: GearSpeedLimits) -> String {
|
pub fn encode_gears_command(limits: GearSpeedLimits) -> String {
|
||||||
let s = limits.sanitized();
|
let s = limits.sanitized();
|
||||||
format!(
|
crate::nomad_elrs::NomadHeadTracker::append_nmea_crc8(&format!(
|
||||||
"$GEARS,{},{},{},{},{},{}\n",
|
"$GEARS,{},{},{},{},{},{}",
|
||||||
s.forward_min,
|
s.forward_min,
|
||||||
s.forward_max[0],
|
s.forward_max[0],
|
||||||
s.forward_max[1],
|
s.forward_max[1],
|
||||||
s.forward_max[2],
|
s.forward_max[2],
|
||||||
s.reverse_min,
|
s.reverse_min,
|
||||||
s.reverse_max,
|
s.reverse_max,
|
||||||
)
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn encode_rc_frame(
|
pub fn encode_rc_frame(
|
||||||
@@ -472,15 +472,15 @@ pub fn encode_rc_frame(
|
|||||||
armed: bool,
|
armed: bool,
|
||||||
gear: i8,
|
gear: i8,
|
||||||
) -> String {
|
) -> String {
|
||||||
format!(
|
crate::nomad_elrs::NomadHeadTracker::append_nmea_crc8(&format!(
|
||||||
"$RC,{},{},{},{},{},{}\n",
|
"$RC,{},{},{},{},{},{}",
|
||||||
steer.clamp(CRSF_CHANNEL_MIN, CRSF_CHANNEL_MAX),
|
steer.clamp(CRSF_CHANNEL_MIN, CRSF_CHANNEL_MAX),
|
||||||
accel.clamp(CRSF_CHANNEL_MIN, CRSF_CHANNEL_MAX),
|
accel.clamp(CRSF_CHANNEL_MIN, CRSF_CHANNEL_MAX),
|
||||||
brake.clamp(CRSF_CHANNEL_MIN, CRSF_CHANNEL_MAX),
|
brake.clamp(CRSF_CHANNEL_MIN, CRSF_CHANNEL_MAX),
|
||||||
clutch.clamp(CRSF_CHANNEL_MIN, CRSF_CHANNEL_MAX),
|
clutch.clamp(CRSF_CHANNEL_MIN, CRSF_CHANNEL_MAX),
|
||||||
if armed { 1 } else { 0 },
|
if armed { 1 } else { 0 },
|
||||||
gear.clamp(-1, 3),
|
gear.clamp(-1, 3),
|
||||||
)
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
@@ -732,6 +732,8 @@ impl OpenEvdevGamepad {
|
|||||||
|
|
||||||
fn query_abs(file: &File, code: u16) -> Option<LinuxInputAbsInfo> {
|
fn query_abs(file: &File, code: u16) -> Option<LinuxInputAbsInfo> {
|
||||||
let mut info = LinuxInputAbsInfo::default();
|
let mut info = LinuxInputAbsInfo::default();
|
||||||
|
// SAFETY: `file` est un fd evdev valide ouvert, `eviocgabs(code)` encode `struct input_absinfo` (24 octets)
|
||||||
|
// et `info` est un `LinuxInputAbsInfo` #[repr(C)] de même taille passé par pointeur mutable valide.
|
||||||
let ret = unsafe {
|
let ret = unsafe {
|
||||||
ioctl(
|
ioctl(
|
||||||
file.as_raw_fd(),
|
file.as_raw_fd(),
|
||||||
@@ -758,6 +760,7 @@ impl OpenEvdevGamepad {
|
|||||||
Ok(n) => {
|
Ok(n) => {
|
||||||
let count = n / EV_SIZE;
|
let count = n / EV_SIZE;
|
||||||
for i in 0..count {
|
for i in 0..count {
|
||||||
|
// SAFETY: `i < n / EV_SIZE` garantit que `i * EV_SIZE + EV_SIZE <= n <= buf.len()`.
|
||||||
let ev = unsafe {
|
let ev = unsafe {
|
||||||
std::ptr::read_unaligned(
|
std::ptr::read_unaligned(
|
||||||
buf.as_ptr().add(i * EV_SIZE) as *const LinuxInputEvent
|
buf.as_ptr().add(i * EV_SIZE) as *const LinuxInputEvent
|
||||||
@@ -1985,18 +1988,25 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_encode_rc_and_src_frames() {
|
fn test_encode_rc_and_src_frames() {
|
||||||
assert_eq!(encode_src_command(ControlSource::G29), "$SRC,G29\n");
|
let check_crc = |frame: String, expected_body: &str| {
|
||||||
assert_eq!(
|
assert!(frame.ends_with('\n'));
|
||||||
encode_src_command(ControlSource::SteamController),
|
let (body, hex_crc) = frame.trim_end_matches('\n').split_once('*').unwrap();
|
||||||
"$SRC,EXT\n"
|
assert_eq!(body, expected_body);
|
||||||
);
|
let expected = format!(
|
||||||
assert_eq!(
|
"{:02X}",
|
||||||
|
crate::nomad_elrs::NomadHeadTracker::crc8_dvb_s2(body.as_bytes())
|
||||||
|
);
|
||||||
|
assert_eq!(hex_crc, expected);
|
||||||
|
};
|
||||||
|
check_crc(encode_src_command(ControlSource::G29), "$SRC,G29");
|
||||||
|
check_crc(encode_src_command(ControlSource::SteamController), "$SRC,EXT");
|
||||||
|
check_crc(
|
||||||
encode_rc_frame(992, 1150, 992, 992, true, 2),
|
encode_rc_frame(992, 1150, 992, 992, true, 2),
|
||||||
"$RC,992,1150,992,992,1,2\n"
|
"$RC,992,1150,992,992,1,2",
|
||||||
);
|
);
|
||||||
assert_eq!(
|
check_crc(
|
||||||
encode_gears_command(GearSpeedLimits::default()),
|
encode_gears_command(GearSpeedLimits::default()),
|
||||||
"$GEARS,1065,1100,1150,1220,905,800\n"
|
"$GEARS,1065,1100,1150,1220,905,800",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+37
-19
@@ -67,7 +67,7 @@ pub struct RuntimeMonitor {
|
|||||||
pub latest_telemetry: TelemetryState,
|
pub latest_telemetry: TelemetryState,
|
||||||
pub latest_g29: G29State,
|
pub latest_g29: G29State,
|
||||||
pub latest_controller: SteamControllerState,
|
pub latest_controller: SteamControllerState,
|
||||||
pub preview_rgba: Vec<u8>,
|
pub preview_rgba: Arc<Vec<u8>>,
|
||||||
pub preview_width: u32,
|
pub preview_width: u32,
|
||||||
pub preview_height: u32,
|
pub preview_height: u32,
|
||||||
pub preview_frame_seq: u64,
|
pub preview_frame_seq: u64,
|
||||||
@@ -99,7 +99,7 @@ impl Default for RuntimeMonitor {
|
|||||||
latest_telemetry: TelemetryState::default(),
|
latest_telemetry: TelemetryState::default(),
|
||||||
latest_g29: G29State::default(),
|
latest_g29: G29State::default(),
|
||||||
latest_controller: SteamControllerState::default(),
|
latest_controller: SteamControllerState::default(),
|
||||||
preview_rgba: Vec::new(),
|
preview_rgba: Arc::new(Vec::new()),
|
||||||
preview_width: 0,
|
preview_width: 0,
|
||||||
preview_height: 0,
|
preview_height: 0,
|
||||||
preview_frame_seq: 0,
|
preview_frame_seq: 0,
|
||||||
@@ -218,24 +218,23 @@ impl EngineControlHandle {
|
|||||||
if current == target {
|
if current == target {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
{
|
// Verrou unique englobant vérification + bascule pour éviter toute race TOCTOU sur l'armement.
|
||||||
let mon = self.monitor_ref.lock();
|
let mut mon = self.monitor_ref.lock();
|
||||||
let armed_now = match current {
|
let armed_now = match current {
|
||||||
ControlSource::G29 => mon.latest_g29.is_live() && mon.latest_g29.armed,
|
ControlSource::G29 => mon.latest_g29.is_live() && mon.latest_g29.armed,
|
||||||
ControlSource::SteamController => mon.latest_controller.armed,
|
ControlSource::SteamController => mon.latest_controller.armed,
|
||||||
};
|
};
|
||||||
if armed_now {
|
if armed_now {
|
||||||
let msg = format!(
|
let msg = format!(
|
||||||
"Bascule vers {} refusée : désarmez d'abord le véhicule !",
|
"Bascule vers {} refusée : désarmez d'abord le véhicule !",
|
||||||
target.label()
|
target.label()
|
||||||
);
|
);
|
||||||
log::warn!("[Contrôleur] {}", msg);
|
log::warn!("[Contrôleur] {}", msg);
|
||||||
return Err(msg);
|
return Err(msg);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
self.control_source_flag
|
self.control_source_flag
|
||||||
.store(target.as_u8(), Ordering::Release);
|
.store(target.as_u8(), Ordering::Release);
|
||||||
self.monitor_ref.lock().active_control_source = target;
|
mon.active_control_source = target;
|
||||||
log::info!(
|
log::info!(
|
||||||
"[Action Utilisateur] Source de conduite basculée sur : {}",
|
"[Action Utilisateur] Source de conduite basculée sur : {}",
|
||||||
target.label()
|
target.label()
|
||||||
@@ -552,10 +551,20 @@ fn sync_telemetry_receiver(
|
|||||||
if !telem_slot.should_retry() {
|
if !telem_slot.should_retry() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let mut allowed_peers = Vec::new();
|
||||||
|
if let Ok(ip) = cfg.radxa_vrx_ip.trim().parse::<std::net::IpAddr>() {
|
||||||
|
allowed_peers.push(ip);
|
||||||
|
}
|
||||||
|
if let Ok(ip) = cfg.nomad_ip.trim().parse::<std::net::IpAddr>() {
|
||||||
|
if !allowed_peers.contains(&ip) {
|
||||||
|
allowed_peers.push(ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
match TelemetryReceiver::start_with_state(
|
match TelemetryReceiver::start_with_state(
|
||||||
&cfg.usb_bind_ip,
|
&cfg.usb_bind_ip,
|
||||||
cfg.telemetry_udp_port,
|
cfg.telemetry_udp_port,
|
||||||
Arc::clone(shared_telem_state),
|
Arc::clone(shared_telem_state),
|
||||||
|
allowed_peers,
|
||||||
) {
|
) {
|
||||||
Ok(rx) => {
|
Ok(rx) => {
|
||||||
monitor.lock().telemetry_status = SubsystemStatus::Running(format!(
|
monitor.lock().telemetry_status = SubsystemStatus::Running(format!(
|
||||||
@@ -885,11 +894,18 @@ fn run_engine_worker(
|
|||||||
|
|
||||||
// 3b. Démarrage optionnel Passerelle Unifiée UDP G29 + Télémétrie CRSF
|
// 3b. Démarrage optionnel Passerelle Unifiée UDP G29 + Télémétrie CRSF
|
||||||
let g29_rx_opt = if cfg.g29_enabled {
|
let g29_rx_opt = if cfg.g29_enabled {
|
||||||
|
let allowed_g29_peers: Vec<std::net::IpAddr> = cfg
|
||||||
|
.radxa_vrx_ip
|
||||||
|
.trim()
|
||||||
|
.parse::<std::net::IpAddr>()
|
||||||
|
.into_iter()
|
||||||
|
.collect();
|
||||||
match G29BridgeReceiver::start(
|
match G29BridgeReceiver::start(
|
||||||
&cfg.usb_bind_ip,
|
&cfg.usb_bind_ip,
|
||||||
cfg.g29_udp_port,
|
cfg.g29_udp_port,
|
||||||
control_for_g29,
|
control_for_g29,
|
||||||
Some(Arc::clone(&shared_telem_state)),
|
Some(Arc::clone(&shared_telem_state)),
|
||||||
|
allowed_g29_peers,
|
||||||
) {
|
) {
|
||||||
Ok(rx) => {
|
Ok(rx) => {
|
||||||
sync_g29_status(&cfg, Some(&rx), &monitor);
|
sync_g29_status(&cfg, Some(&rx), &monitor);
|
||||||
@@ -1429,6 +1445,7 @@ fn try_run_openxr_session(
|
|||||||
|
|
||||||
if standby_tick % 2 == 0 || last_frame_id % 2 == 0 {
|
if standby_tick % 2 == 0 || last_frame_id % 2 == 0 {
|
||||||
sync_video_status(cfg, video_rx_opt, monitor);
|
sync_video_status(cfg, video_rx_opt, monitor);
|
||||||
|
let preview_arc = Arc::new(composited_rgba.clone());
|
||||||
let mut mon = monitor.lock();
|
let mut mon = monitor.lock();
|
||||||
if fps_timer.elapsed() >= Duration::from_secs(1) {
|
if fps_timer.elapsed() >= Duration::from_secs(1) {
|
||||||
if has_video_stream {
|
if has_video_stream {
|
||||||
@@ -1455,7 +1472,7 @@ fn try_run_openxr_session(
|
|||||||
mon.latest_telemetry = telem_snapshot;
|
mon.latest_telemetry = telem_snapshot;
|
||||||
mon.preview_width = cfg.video_width;
|
mon.preview_width = cfg.video_width;
|
||||||
mon.preview_height = cfg.video_height;
|
mon.preview_height = cfg.video_height;
|
||||||
mon.preview_rgba.clone_from(&composited_rgba);
|
mon.preview_rgba = preview_arc;
|
||||||
mon.preview_frame_seq = mon.preview_frame_seq.wrapping_add(1);
|
mon.preview_frame_seq = mon.preview_frame_seq.wrapping_add(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1755,6 +1772,7 @@ fn run_desktop_fallback_loop(
|
|||||||
}
|
}
|
||||||
|
|
||||||
sync_video_status(cfg, video_rx_opt, monitor);
|
sync_video_status(cfg, video_rx_opt, monitor);
|
||||||
|
let preview_arc = Arc::new(composited_rgba.clone());
|
||||||
{
|
{
|
||||||
let mut mon = monitor.lock();
|
let mut mon = monitor.lock();
|
||||||
if fps_timer.elapsed() >= Duration::from_secs(1) {
|
if fps_timer.elapsed() >= Duration::from_secs(1) {
|
||||||
@@ -1782,7 +1800,7 @@ fn run_desktop_fallback_loop(
|
|||||||
mon.latest_telemetry = telem_snapshot;
|
mon.latest_telemetry = telem_snapshot;
|
||||||
mon.preview_width = cfg.video_width;
|
mon.preview_width = cfg.video_width;
|
||||||
mon.preview_height = cfg.video_height;
|
mon.preview_height = cfg.video_height;
|
||||||
mon.preview_rgba.clone_from(&composited_rgba);
|
mon.preview_rgba = preview_arc;
|
||||||
mon.preview_frame_seq = mon.preview_frame_seq.wrapping_add(1);
|
mon.preview_frame_seq = mon.preview_frame_seq.wrapping_add(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+44
-2
@@ -155,11 +155,16 @@ impl G29BridgeReceiver {
|
|||||||
port: u16,
|
port: u16,
|
||||||
control: EngineControlHandle,
|
control: EngineControlHandle,
|
||||||
telemetry: Option<Arc<Mutex<TelemetryState>>>,
|
telemetry: Option<Arc<Mutex<TelemetryState>>>,
|
||||||
|
allowed_peers: Vec<std::net::IpAddr>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let addr = format!("{}:{}", bind_ip, port);
|
let addr = format!("{}:{}", bind_ip, port);
|
||||||
let socket = UdpSocket::bind(&addr)?;
|
let socket = UdpSocket::bind(&addr)?;
|
||||||
socket.set_read_timeout(Some(Duration::from_millis(100)))?;
|
socket.set_read_timeout(Some(Duration::from_millis(100)))?;
|
||||||
log::info!("[G29 Bridge] En écoute UDP unifiée sur {}", addr);
|
log::info!(
|
||||||
|
"[G29 Bridge] En écoute UDP unifiée sur {} (pairs autorisés: {:?})",
|
||||||
|
addr,
|
||||||
|
allowed_peers
|
||||||
|
);
|
||||||
|
|
||||||
let state = Arc::new(Mutex::new(G29State::default()));
|
let state = Arc::new(Mutex::new(G29State::default()));
|
||||||
let state_clone = Arc::clone(&state);
|
let state_clone = Arc::clone(&state);
|
||||||
@@ -170,8 +175,19 @@ impl G29BridgeReceiver {
|
|||||||
.name("g29-udp-rx".into())
|
.name("g29-udp-rx".into())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
let mut buf = [0u8; 512];
|
let mut buf = [0u8; 512];
|
||||||
|
let mut last_reject_log = Instant::now() - Duration::from_secs(10);
|
||||||
while !stop_clone.load(Ordering::Acquire) {
|
while !stop_clone.load(Ordering::Acquire) {
|
||||||
if let Ok((len, _src)) = socket.recv_from(&mut buf) {
|
if let Ok((len, src)) = socket.recv_from(&mut buf) {
|
||||||
|
if !Self::is_peer_allowed(src.ip(), &allowed_peers) {
|
||||||
|
if last_reject_log.elapsed() >= Duration::from_secs(5) {
|
||||||
|
log::warn!(
|
||||||
|
"[G29 Bridge] Paquet UDP rejeté depuis IP non autorisée : {}",
|
||||||
|
src
|
||||||
|
);
|
||||||
|
last_reject_log = Instant::now();
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if let Ok(text) = std::str::from_utf8(&buf[..len]) {
|
if let Ok(text) = std::str::from_utf8(&buf[..len]) {
|
||||||
for line in text.lines() {
|
for line in text.lines() {
|
||||||
Self::process_line(
|
Self::process_line(
|
||||||
@@ -213,6 +229,10 @@ impl G29BridgeReceiver {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_peer_allowed(src_ip: std::net::IpAddr, allowed_peers: &[std::net::IpAddr]) -> bool {
|
||||||
|
src_ip.is_loopback() || allowed_peers.is_empty() || allowed_peers.contains(&src_ip)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn state(&self) -> Arc<Mutex<G29State>> {
|
pub fn state(&self) -> Arc<Mutex<G29State>> {
|
||||||
Arc::clone(&self.state)
|
Arc::clone(&self.state)
|
||||||
}
|
}
|
||||||
@@ -553,4 +573,26 @@ mod tests {
|
|||||||
assert!((ts.battery_current_a - 12.5).abs() < 0.01);
|
assert!((ts.battery_current_a - 12.5).abs() < 0.01);
|
||||||
assert_eq!(ts.battery_remaining_pct, 75);
|
assert_eq!(ts.battery_remaining_pct, 75);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_udp_peer_allowlist() {
|
||||||
|
use std::net::{IpAddr, Ipv4Addr};
|
||||||
|
let allowed = vec![IpAddr::V4(Ipv4Addr::new(192, 168, 1, 1))];
|
||||||
|
assert!(G29BridgeReceiver::is_peer_allowed(
|
||||||
|
IpAddr::V4(Ipv4Addr::new(192, 168, 1, 1)),
|
||||||
|
&allowed
|
||||||
|
));
|
||||||
|
assert!(G29BridgeReceiver::is_peer_allowed(
|
||||||
|
IpAddr::V4(Ipv4Addr::LOCALHOST),
|
||||||
|
&allowed
|
||||||
|
));
|
||||||
|
assert!(!G29BridgeReceiver::is_peer_allowed(
|
||||||
|
IpAddr::V4(Ipv4Addr::new(10, 0, 0, 99)),
|
||||||
|
&allowed
|
||||||
|
));
|
||||||
|
assert!(G29BridgeReceiver::is_peer_allowed(
|
||||||
|
IpAddr::V4(Ipv4Addr::new(10, 0, 0, 99)),
|
||||||
|
&[]
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+5
-4
@@ -258,14 +258,14 @@ impl SteamFrameGpuiApp {
|
|||||||
}
|
}
|
||||||
self.latest_controller = mon.latest_controller.clone();
|
self.latest_controller = mon.latest_controller.clone();
|
||||||
|
|
||||||
// Ne cloner et décoder la trame QUE si l'onglet Cockpit est actif !
|
// Ne cloner que le pointeur Arc sous verrou ; la copie/conversion BGRA se fait hors verrou !
|
||||||
let frame_data: Option<(u32, u32, Vec<u8>)> = if self.active_tab == ActiveTab::Cockpit
|
let frame_data: Option<(u32, u32, Arc<Vec<u8>>)> = if self.active_tab == ActiveTab::Cockpit
|
||||||
&& mon.preview_frame_seq != self.last_frame_seq
|
&& mon.preview_frame_seq != self.last_frame_seq
|
||||||
&& !mon.preview_rgba.is_empty()
|
&& !mon.preview_rgba.is_empty()
|
||||||
&& mon.preview_width > 0
|
&& mon.preview_width > 0
|
||||||
&& mon.preview_height > 0
|
&& mon.preview_height > 0
|
||||||
{
|
{
|
||||||
Some((mon.preview_width, mon.preview_height, mon.preview_rgba.clone()))
|
Some((mon.preview_width, mon.preview_height, Arc::clone(&mon.preview_rgba)))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
@@ -274,7 +274,8 @@ impl SteamFrameGpuiApp {
|
|||||||
}; // Verrou `engine_monitor` immédiatement libéré !
|
}; // Verrou `engine_monitor` immédiatement libéré !
|
||||||
|
|
||||||
// 2. Conversion BGRA et allocation GPU hors du verrou monitor
|
// 2. Conversion BGRA et allocation GPU hors du verrou monitor
|
||||||
if let Some((w, h, mut raw_buf)) = new_frame_data {
|
if let Some((w, h, raw_arc)) = new_frame_data {
|
||||||
|
let mut raw_buf = (*raw_arc).clone();
|
||||||
for pixel in raw_buf.chunks_exact_mut(4) {
|
for pixel in raw_buf.chunks_exact_mut(4) {
|
||||||
pixel.swap(0, 2);
|
pixel.swap(0, 2);
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-5
@@ -272,8 +272,14 @@ impl NomadHeadTracker {
|
|||||||
(crsf_val.round() as u16).clamp(CRSF_CHANNEL_MIN, CRSF_CHANNEL_MAX)
|
(crsf_val.round() as u16).clamp(CRSF_CHANNEL_MIN, CRSF_CHANNEL_MAX)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Ajoute un suffixe CRC-8 DVB-S2 (`*XX\n`) à une trame texte `$...` pour validation UART RP2350.
|
||||||
|
pub fn append_nmea_crc8(payload: &str) -> String {
|
||||||
|
let crc = Self::crc8_dvb_s2(payload.as_bytes());
|
||||||
|
format!("{}*{:02X}\n", payload, crc)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn encode_g29_ht(pan: u16, tilt: u16, roll: u16) -> String {
|
pub fn encode_g29_ht(pan: u16, tilt: u16, roll: u16) -> String {
|
||||||
format!("$HT,{},{},{}\n", pan, tilt, roll)
|
Self::append_nmea_crc8(&format!("$HT,{},{},{}", pan, tilt, roll))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn encode_mspv2_ptr(pan: u16, tilt: u16, roll: u16) -> [u8; 15] {
|
pub fn encode_mspv2_ptr(pan: u16, tilt: u16, roll: u16) -> [u8; 15] {
|
||||||
@@ -494,9 +500,10 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_g29_bridge_ht_format() {
|
fn test_g29_bridge_ht_format() {
|
||||||
assert_eq!(NomadProtocol::from_str("g29"), NomadProtocol::G29Bridge);
|
assert_eq!(NomadProtocol::from_str("g29"), NomadProtocol::G29Bridge);
|
||||||
assert_eq!(
|
let frame = NomadHeadTracker::encode_g29_ht(992, 1200, 800);
|
||||||
NomadHeadTracker::encode_g29_ht(992, 1200, 800),
|
let (body, hex_crc) = frame.trim_end_matches('\n').split_once('*').unwrap();
|
||||||
"$HT,992,1200,800\n"
|
assert_eq!(body, "$HT,992,1200,800");
|
||||||
);
|
let expected = format!("{:02X}", NomadHeadTracker::crc8_dvb_s2(body.as_bytes()));
|
||||||
|
assert_eq!(hex_crc, expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+25
-4
@@ -149,13 +149,19 @@ pub struct TelemetryReceiver {
|
|||||||
impl TelemetryReceiver {
|
impl TelemetryReceiver {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn start(bind_ip: &str, port: u16) -> Result<Self> {
|
pub fn start(bind_ip: &str, port: u16) -> Result<Self> {
|
||||||
Self::start_with_state(bind_ip, port, Arc::new(Mutex::new(TelemetryState::default())))
|
Self::start_with_state(
|
||||||
|
bind_ip,
|
||||||
|
port,
|
||||||
|
Arc::new(Mutex::new(TelemetryState::default())),
|
||||||
|
Vec::new(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_with_state(
|
pub fn start_with_state(
|
||||||
bind_ip: &str,
|
bind_ip: &str,
|
||||||
port: u16,
|
port: u16,
|
||||||
state: Arc<Mutex<TelemetryState>>,
|
state: Arc<Mutex<TelemetryState>>,
|
||||||
|
allowed_peers: Vec<std::net::IpAddr>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let addr = format!("{}:{}", bind_ip, port);
|
let addr = format!("{}:{}", bind_ip, port);
|
||||||
let socket = UdpSocket::bind(&addr).map_err(|e| {
|
let socket = UdpSocket::bind(&addr).map_err(|e| {
|
||||||
@@ -168,8 +174,9 @@ impl TelemetryReceiver {
|
|||||||
})?;
|
})?;
|
||||||
socket.set_read_timeout(Some(Duration::from_millis(100)))?;
|
socket.set_read_timeout(Some(Duration::from_millis(100)))?;
|
||||||
log::info!(
|
log::info!(
|
||||||
"[Télémétrie OSD] Récepteur MAVLink / CRSF en écoute sur UDP {}",
|
"[Télémétrie OSD] Récepteur MAVLink / CRSF en écoute sur UDP {} (pairs autorisés: {:?})",
|
||||||
addr
|
addr,
|
||||||
|
allowed_peers
|
||||||
);
|
);
|
||||||
|
|
||||||
let state_clone = Arc::clone(&state);
|
let state_clone = Arc::clone(&state);
|
||||||
@@ -180,8 +187,22 @@ impl TelemetryReceiver {
|
|||||||
.name("telemetry-udp-rx".into())
|
.name("telemetry-udp-rx".into())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
let mut buf = [0u8; 1024];
|
let mut buf = [0u8; 1024];
|
||||||
|
let mut last_reject_log = Instant::now() - Duration::from_secs(10);
|
||||||
while !stop_clone.load(Ordering::Acquire) {
|
while !stop_clone.load(Ordering::Acquire) {
|
||||||
if let Ok((len, _src)) = socket.recv_from(&mut buf) {
|
if let Ok((len, src)) = socket.recv_from(&mut buf) {
|
||||||
|
if !src.ip().is_loopback()
|
||||||
|
&& !allowed_peers.is_empty()
|
||||||
|
&& !allowed_peers.contains(&src.ip())
|
||||||
|
{
|
||||||
|
if last_reject_log.elapsed() >= Duration::from_secs(5) {
|
||||||
|
log::warn!(
|
||||||
|
"[Télémétrie OSD] Paquet UDP rejeté depuis IP non autorisée : {}",
|
||||||
|
src
|
||||||
|
);
|
||||||
|
last_reject_log = Instant::now();
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Self::parse_datagram(&buf[..len], &state_clone);
|
Self::parse_datagram(&buf[..len], &state_clone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-2
@@ -28,6 +28,9 @@ pub struct VulkanXrContext {
|
|||||||
pub height: u32,
|
pub height: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SAFETY: VulkanXrContext ne partage aucun accès mutable concurrent (pas de `Sync`) ;
|
||||||
|
// le transfert entre threads est sûr tant que le contexte est utilisé exclusivement
|
||||||
|
// depuis le thread de rendu OpenXR propriétaire via `&mut self`.
|
||||||
unsafe impl Send for VulkanXrContext {}
|
unsafe impl Send for VulkanXrContext {}
|
||||||
|
|
||||||
impl VulkanXrContext {
|
impl VulkanXrContext {
|
||||||
@@ -66,7 +69,10 @@ impl VulkanXrContext {
|
|||||||
xr_instance
|
xr_instance
|
||||||
.create_vulkan_instance(
|
.create_vulkan_instance(
|
||||||
system,
|
system,
|
||||||
std::mem::transmute(vk_entry.static_fn().get_instance_proc_addr),
|
// SAFETY: vkGetInstanceProcAddr d'ash a exactement l'ABI C PFN_vkGetInstanceProcAddr attendue par openxr.
|
||||||
|
std::mem::transmute::<vk::PFN_vkGetInstanceProcAddr, _>(
|
||||||
|
vk_entry.static_fn().get_instance_proc_addr,
|
||||||
|
),
|
||||||
&vk_instance_create_info as *const _ as *const _,
|
&vk_instance_create_info as *const _ as *const _,
|
||||||
)
|
)
|
||||||
.context("Échec de xrCreateVulkanInstanceKHR")?
|
.context("Échec de xrCreateVulkanInstanceKHR")?
|
||||||
@@ -116,7 +122,10 @@ impl VulkanXrContext {
|
|||||||
xr_instance
|
xr_instance
|
||||||
.create_vulkan_device(
|
.create_vulkan_device(
|
||||||
system,
|
system,
|
||||||
std::mem::transmute(vk_entry.static_fn().get_instance_proc_addr),
|
// SAFETY: vkGetInstanceProcAddr d'ash a exactement l'ABI C PFN_vkGetInstanceProcAddr attendue par openxr.
|
||||||
|
std::mem::transmute::<vk::PFN_vkGetInstanceProcAddr, _>(
|
||||||
|
vk_entry.static_fn().get_instance_proc_addr,
|
||||||
|
),
|
||||||
phys_device.as_raw() as _,
|
phys_device.as_raw() as _,
|
||||||
&device_create_info as *const _ as *const _,
|
&device_create_info as *const _ as *const _,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user