Keepalive Canon anti-veille : get_config() toutes les 10s quand preview KO

Quand capture_preview() echoue (I/O error, miroir bloque), le thread
preview n'envoyait plus de commande PTP au Canon → l'appareil finissait
par s'eteindre via auto power off. Ajoute un keepalive de secours via
get_config() qui declenche ptp_canon_eos_keepdeviceon cote libgphoto2.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-27 00:21:59 +02:00
parent 5a81907a0e
commit 29e65ab1bd
2 changed files with 22 additions and 2 deletions

View File

@@ -330,6 +330,18 @@ class Camera:
except Exception as e:
log.warning(f"Viewfinder non supporté : {e}")
def keepalive(self) -> bool:
"""Envoie une commande legere au Canon pour empecher l'auto power off.
Utilise get_config qui declenche internement ptp_canon_eos_keepdeviceon."""
if self.mode != "gphoto2" or not self.connectee or not self.camera:
return False
try:
with self._gp_lock:
self.camera.get_config()
return True
except Exception:
return False
def _preview_gphoto2(self) -> bytes | None:
try:
with self._gp_lock: