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
|
global _reveil_en_cours
|
||||||
_reveil_en_cours = True
|
_reveil_en_cours = True
|
||||||
try:
|
try:
|
||||||
log.info("Réveil Canon — restauration alimentation relais")
|
log.info("Réveil Canon — restauration alimentation")
|
||||||
relais.desactiver("canon")
|
relais.desactiver("canon")
|
||||||
time.sleep(15)
|
time.sleep(3)
|
||||||
relais.desactiver("canon_usb")
|
relais.desactiver("canon_usb")
|
||||||
time.sleep(25)
|
|
||||||
|
# Poll USB au lieu d'attendre un temps fixe (max 20s)
|
||||||
|
for i in range(20):
|
||||||
|
time.sleep(1)
|
||||||
if _canon_sur_usb():
|
if _canon_sur_usb():
|
||||||
log.info("Canon visible USB après réveil — connexion...")
|
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")
|
camera.connecter(source="gphoto2")
|
||||||
if camera.connectee:
|
if camera.connectee:
|
||||||
_appliquer_config_camera()
|
_appliquer_config_camera()
|
||||||
_canon_stats["derniere_preview"] = time.time()
|
_canon_stats["derniere_preview"] = time.time()
|
||||||
_canon_stats["derniere_capture"] = time.time()
|
_canon_stats["derniere_capture"] = time.time()
|
||||||
log.info("Canon reconnecté après réveil")
|
|
||||||
_canon_stats["connexions"] += 1
|
_canon_stats["connexions"] += 1
|
||||||
else:
|
log.info(f"Canon reconnecté après réveil (tentative {tentative+1})")
|
||||||
log.warning("Canon visible USB mais connexion gphoto2 échouée")
|
return
|
||||||
else:
|
log.warning(f"Connexion gphoto2 échouée (tentative {tentative+1}/3)")
|
||||||
log.warning("Canon absent USB après réveil relais — vérifier branchement physique")
|
time.sleep(3)
|
||||||
|
log.error("Canon visible USB mais connexion gphoto2 échouée après 3 tentatives")
|
||||||
finally:
|
finally:
|
||||||
_reveil_en_cours = False
|
_reveil_en_cours = False
|
||||||
|
|
||||||
|
|||||||
@@ -1146,7 +1146,7 @@
|
|||||||
|
|
||||||
<script src="/js/websocket.js?v=16"></script>
|
<script src="/js/websocket.js?v=16"></script>
|
||||||
<script src="/js/app.js?v=25"></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/effects.js?v=4"></script>
|
||||||
<script src="/js/gallery.js?v=5"></script>
|
<script src="/js/gallery.js?v=5"></script>
|
||||||
<script src="/js/share.js?v=9"></script>
|
<script src="/js/share.js?v=9"></script>
|
||||||
|
|||||||
@@ -280,12 +280,13 @@ async function lancerCapture() {
|
|||||||
await chargerCadreImpose();
|
await chargerCadreImpose();
|
||||||
majCompteurAccueil();
|
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 {
|
try {
|
||||||
let statut = await apiGet('/api/camera/statut');
|
let statut = await apiGet('/api/camera/statut');
|
||||||
if ((!statut.connectee || statut.mode === 'erreur') && statut.reveil_en_cours) {
|
if (!statut.connectee || statut.mode === 'erreur') {
|
||||||
afficherStatut('L\'appareil photo se prepare, un instant...', 'succes');
|
afficherStatut('Preparation de l\'appareil photo...', 'succes');
|
||||||
for (let att = 0; att < 30; att++) {
|
// Attendre jusqu'a 40s que le Canon soit pret (reveil ou reconnexion)
|
||||||
|
for (let att = 0; att < 20; att++) {
|
||||||
await pause(2000);
|
await pause(2000);
|
||||||
statut = await apiGet('/api/camera/statut');
|
statut = await apiGet('/api/camera/statut');
|
||||||
if (statut.connectee && statut.mode !== 'erreur') break;
|
if (statut.connectee && statut.mode !== 'erreur') break;
|
||||||
@@ -294,12 +295,12 @@ async function lancerCapture() {
|
|||||||
}
|
}
|
||||||
if (!statut.connectee || statut.mode === 'erreur') {
|
if (!statut.connectee || statut.mode === 'erreur') {
|
||||||
captureEnCours = false;
|
captureEnCours = false;
|
||||||
afficherErreurCapture('Appareil photo indisponible', 'Reessayez dans quelques instants');
|
afficherErreurCapture('Appareil photo indisponible', 'Touchez l\'ecran et reessayez');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
captureEnCours = false;
|
captureEnCours = false;
|
||||||
afficherErreurCapture('Le photobooth demarre', 'Reessayez dans quelques instants');
|
afficherErreurCapture('Preparation en cours', 'Touchez l\'ecran et reessayez');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user