Reveil Canon fiabilise : poll USB au lieu de sleep fixe, retry gphoto2, frontend patient
Backend: reveiller_canon() poll USB toutes les 1s (max 20s) au lieu de sleep(15+25),
3 tentatives gphoto2, temps total 10-30s au lieu de 40s fixe.
Frontend: attend 40s meme si reveil_en_cours=false (reconnexion auto),
messages plus clairs ("Touchez l'ecran et reessayez").
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -651,24 +651,37 @@ def _reveiller_canon():
|
||||
global _reveil_en_cours
|
||||
_reveil_en_cours = True
|
||||
try:
|
||||
log.info("Réveil Canon — restauration alimentation relais")
|
||||
log.info("Réveil Canon — restauration alimentation")
|
||||
relais.desactiver("canon")
|
||||
time.sleep(15)
|
||||
time.sleep(3)
|
||||
relais.desactiver("canon_usb")
|
||||
time.sleep(25)
|
||||
if _canon_sur_usb():
|
||||
log.info("Canon visible USB après réveil — connexion...")
|
||||
|
||||
# Poll USB au lieu d'attendre un temps fixe (max 20s)
|
||||
for i in range(20):
|
||||
time.sleep(1)
|
||||
if _canon_sur_usb():
|
||||
log.info(f"Canon visible USB après {i+4}s — connexion gphoto2...")
|
||||
break
|
||||
else:
|
||||
log.warning("Canon absent USB après 24s — vérifier branchement physique")
|
||||
return
|
||||
|
||||
# Laisser le Canon finir son init PTP
|
||||
time.sleep(3)
|
||||
|
||||
# Tentatives connexion gphoto2 (max 3)
|
||||
for tentative in range(3):
|
||||
camera.connecter(source="gphoto2")
|
||||
if camera.connectee:
|
||||
_appliquer_config_camera()
|
||||
_canon_stats["derniere_preview"] = time.time()
|
||||
_canon_stats["derniere_capture"] = time.time()
|
||||
log.info("Canon reconnecté après réveil")
|
||||
_canon_stats["connexions"] += 1
|
||||
else:
|
||||
log.warning("Canon visible USB mais connexion gphoto2 échouée")
|
||||
else:
|
||||
log.warning("Canon absent USB après réveil relais — vérifier branchement physique")
|
||||
log.info(f"Canon reconnecté après réveil (tentative {tentative+1})")
|
||||
return
|
||||
log.warning(f"Connexion gphoto2 échouée (tentative {tentative+1}/3)")
|
||||
time.sleep(3)
|
||||
log.error("Canon visible USB mais connexion gphoto2 échouée après 3 tentatives")
|
||||
finally:
|
||||
_reveil_en_cours = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user