Skip to content

Commit a7089f2

Browse files
committed
Avoid logging errors caused by pins being in use.
1 parent 97be984 commit a7089f2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

myDevices/devices/digital/gpio.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ def __checkFilesystemExport__(self, channel):
179179
f.write("%s" % channel)
180180
except PermissionError:
181181
command = 'sudo python3 -m myDevices.devices.writevalue -f /sys/class/gpio/export -t {}'.format(channel)
182-
executeCommand(command)
182+
executeCommand(command)
183+
except OSError as ex:
184+
debug(ex)
185+
return False
183186
except Exception as ex:
184187
error('Failed on __checkFilesystemExport__: ' + str(channel) + ' ' + str(ex))
185188
return False
@@ -204,7 +207,6 @@ def __checkFilesystemFunction__(self, channel):
204207
# since there is a delay when the gpio channel is first exported
205208
sleep(0.01)
206209

207-
208210
def __checkFilesystemValue__(self, channel):
209211
if not self.valueFile[channel]:
210212
#debug("value file %d not open" %channel)
@@ -286,9 +288,11 @@ def __getFunction__(self, channel):
286288
return self.OUT
287289
else:
288290
return self.IN
291+
except AttributeError:
292+
debug('AttributeError in __getFunction__: '+ str(channel) + ' ' + str(ex))
289293
except Exception as ex:
290294
error('Failed on __getFunction__: '+ str(channel) + ' ' + str(ex))
291-
return -1
295+
return -1
292296

293297
def __setFunction__(self, channel, value):
294298
self.__checkFilesystemFunction__(channel)

0 commit comments

Comments
 (0)