From 5e10ebc2ac3c5e28007d1f0c7b95ae61130ed6e7 Mon Sep 17 00:00:00 2001 From: Martin Sekera Date: Fri, 30 Jul 2021 00:31:31 +0200 Subject: [PATCH] fix crash on init caused by the previous change (2/2) --- fand.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fand.py b/fand.py index 0976568..b8ae87a 100755 --- a/fand.py +++ b/fand.py @@ -49,8 +49,12 @@ class PWM: # acquire a duty cycle file descriptor self.f_dc = open(self.ch_base + "duty_cycle", "w") - # set 0 duty cycle so period can be freely set - self.set_duty_cycle(0) + # Set 0 duty cycle so period can be freely set even if the channel was used before. + # This may fail: ignore. + try: + self.set_duty_cycle(0) + except OSError: + pass # set period & polarity with open(self.ch_base + "period", "w") as f: