From e03044f862b12538278afcbf1dec6fa73176fdee Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Mon, 12 Aug 2019 14:12:13 +0200 Subject: [PATCH] bindings: python: examples: make gpiomon.py output resemble the original Modify the gpiomon.py example to describe the detected events in a format similar to the one used by the original gpiomon tool. Signed-off-by: Bartosz Golaszewski --- bindings/python/examples/gpiomon.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bindings/python/examples/gpiomon.py b/bindings/python/examples/gpiomon.py index 9cb71da..2615f4a 100755 --- a/bindings/python/examples/gpiomon.py +++ b/bindings/python/examples/gpiomon.py @@ -14,13 +14,15 @@ import sys def print_event(event): if event.type == gpiod.LineEvent.RISING_EDGE: - print(' RISING EDGE', end='') + evstr = ' RISING EDGE' elif event.type == gpiod.LineEvent.FALLING_EDGE: - print('FALLING EDGE', end='') + evstr = 'FALLING EDGE' else: raise TypeError('Invalid event type') - print(' {}.{} line: {}'.format(event.sec, event.nsec, event.source.offset())) + print('event: {} offset: {} timestamp: [{}.{}]'.format(evstr, + event.source.offset(), + event.sec, event.nsec)) if len(sys.argv) < 3: raise TypeError('usage: gpiomon.py ...') -- 2.30.2