Re: [libgpiod][PATCH 1/4] bindings: python: examples: replace tools examples with use case examples

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 26, 2023 at 10:18 AM Kent Gibson <warthog618@xxxxxxxxx> wrote:
>
> On Mon, Jun 26, 2023 at 10:02:33AM +0200, Bartosz Golaszewski wrote:
> > On Sat, Jun 24, 2023 at 7:21 AM Kent Gibson <warthog618@xxxxxxxxx> wrote:
> > >
> > > Replace tool examples with use case examples drawn from the tools.
> > > +        while True:
> > > +            # Blocks until at least one event is available
> > > +            for event in request.read_edge_events():
> > > +                print(
> > > +                    "line: %d  type: Rising   event #%d"
> > > +                    % (event.line_offset, event.line_seqno)
> > > +                )
> >
> > This still uses the old style formatting.
> >
>
> Well spotted.
> I only fixed the one you pointed out - didn't even consider that there
> could be others.  Turns out there are a few - probably all
> cut-and-paste.
>
> > > +
> > > +
> > > +if __name__ == "__main__":
> > > +    try:
> > > +        watch_line_rising("/dev/gpiochip0", 5)
> > > +    except OSError as ex:
> > > +        print(ex, "\nCustomise the example configuration to suit your situation")
> > > diff --git a/bindings/python/examples/watch_multiple_line_values.py b/bindings/python/examples/watch_multiple_line_values.py
> > > new file mode 100755
> > > index 0000000..658ecee
> > > --- /dev/null
> > > +++ b/bindings/python/examples/watch_multiple_line_values.py
> > > @@ -0,0 +1,42 @@
> > > +#!/usr/bin/env python3
> > > +# SPDX-License-Identifier: GPL-2.0-or-later
> > > +# SPDX-FileCopyrightText: 2023 Kent Gibson <warthog618@xxxxxxxxx>
> > > +
> > > +"""Minimal example of watching for edges on multiple lines."""
> > > +
> > > +import gpiod
> > > +
> > > +from gpiod.line import Edge
> > > +
> > > +
> > > +def edge_type(event):
> > > +    if event.event_type is event.Type.RISING_EDGE:
> > > +        return "Rising"
> > > +    if event.event_type is event.Type.FALLING_EDGE:
> > > +        return "Falling"
> > > +    return "Unknown"
> > > +
> >
> > As there'll be another iteration, maybe change this to get_edge_type()
> > or get_edge_event_type_str()? I have a preference for function names
> > to reflect the action in general.
> >
>
> Yeah, I use _str elsewhere, not sure why I didn't here.
>
> What an I supposed to resend the update as given the remainder of
> the series was merged - v3??
>

Just this patch marked as v3 is fine.

Bart

> Cheers,
> Kent.




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux