Skip to content

Commit 28dfde7

Browse files
committed
* Access errno
1 parent 1dc3a95 commit 28dfde7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
trio-gpio (0.2.2-1) unstable; urgency=medium
2+
3+
* Access errno
4+
5+
-- Matthias Urlichs <[email protected]> Mon, 11 Jun 2018 08:29:53 +0200
6+
17
trio-gpio (0.2.1-1) unstable; urgency=medium
28

39
* Allow (and prefer) the GPIO chip label instead of its number.

trio_gpio/gpio.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ def _enter_io(self):
137137
self.__exit__()
138138
raise RuntimeError("Unknown direction", r)
139139
if r != 0:
140+
if r < 0:
141+
r = gpio.ffi.errno
140142
self.__exit__()
141143
raise OSError("unable to set direction", r)
142144
self._state = _IN_IO
@@ -149,7 +151,7 @@ def _enter_ev(self):
149151
req.flags = self._flags
150152

151153
if gpio.lib.gpiod_line_request(self._line, req, 0) != 0:
152-
raise OSError("unable to request event monitoring")
154+
raise OSError("unable to request event monitoring", gpio.ffi.errno)
153155
self._state = _IN_EV
154156

155157
def __exit__(self, *tb):
@@ -277,7 +279,9 @@ async def __anext__(self):
277279
self._is_open()
278280
r = gpio.lib.gpiod_line_event_read_fd(fd, ev)
279281
if r != 0:
280-
raise OSError("unable to read update")
282+
if r < 0:
283+
r = gpio.ffi.errno
284+
raise OSError("unable to read update", r)
281285
return Event(ev)
282286

283287
async def aclose(self):

0 commit comments

Comments
 (0)