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:
2026-09-18 09:46:29 +02:00
parent be838a7a48
commit 6c45faecdc
3 changed files with 31 additions and 17 deletions

View File

@@ -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

View File

@@ -1146,7 +1146,7 @@
<script src="/js/websocket.js?v=16"></script>
<script src="/js/app.js?v=25"></script>
<script src="/js/camera.js?v=22"></script>
<script src="/js/camera.js?v=23"></script>
<script src="/js/effects.js?v=4"></script>
<script src="/js/gallery.js?v=5"></script>
<script src="/js/share.js?v=9"></script>

View File

@@ -280,12 +280,13 @@ async function lancerCapture() {
await chargerCadreImpose();
majCompteurAccueil();
// Verifier l'etat de la camera — attendre si reveil en cours
// Verifier l'etat de la camera — attendre si pas prete ou reveil en cours
try {
let statut = await apiGet('/api/camera/statut');
if ((!statut.connectee || statut.mode === 'erreur') && statut.reveil_en_cours) {
afficherStatut('L\'appareil photo se prepare, un instant...', 'succes');
for (let att = 0; att < 30; att++) {
if (!statut.connectee || statut.mode === 'erreur') {
afficherStatut('Preparation de l\'appareil photo...', 'succes');
// Attendre jusqu'a 40s que le Canon soit pret (reveil ou reconnexion)
for (let att = 0; att < 20; att++) {
await pause(2000);
statut = await apiGet('/api/camera/statut');
if (statut.connectee && statut.mode !== 'erreur') break;
@@ -294,12 +295,12 @@ async function lancerCapture() {
}
if (!statut.connectee || statut.mode === 'erreur') {
captureEnCours = false;
afficherErreurCapture('Appareil photo indisponible', 'Reessayez dans quelques instants');
afficherErreurCapture('Appareil photo indisponible', 'Touchez l\'ecran et reessayez');
return;
}
} catch (e) {
captureEnCours = false;
afficherErreurCapture('Le photobooth demarre', 'Reessayez dans quelques instants');
afficherErreurCapture('Preparation en cours', 'Touchez l\'ecran et reessayez');
return;
}