From: Kent Gibson <warthog618@gmail.com>
To: chuang+git@melty.land
Cc: linux-gpio@vger.kernel.org, Chuang Zhu <git@chuang.cz>,
Bartosz Golaszewski <brgl@bgdev.pl>
Subject: Re: [libgpiod][PATCH] bindings: python: fix LineRequest.set_value only works for the last entry
Date: Tue, 25 Jun 2024 19:09:51 +0800 [thread overview]
Message-ID: <20240625110951.GB71664@rigel> (raw)
In-Reply-To: <20240625105342.GA71664@rigel>
On Tue, Jun 25, 2024 at 06:53:42PM +0800, Kent Gibson wrote:
> On Tue, Jun 25, 2024 at 09:15:22AM +0800, chuang+git@melty.land wrote:
> > From: Chuang Zhu <git@chuang.cz>
> >
> > When multiple entries are requested using line names in
> > Chip.request_lines, only the the last entry is added to
> > LineRequest._name_map, causing a ValueError when trying to use
> > LineRequest.set_value on any former entries.
> >
> > >>> import gpiod
> > >>> lr = gpiod.Chip('/dev/gpiochip0').request_lines(
> > ... config={
> > ... 'LINE0': gpiod.LineSettings(direction=gpiod.line.Direction.OUTPUT,
> > ... output_value=gpiod.line.Value.INACTIVE),
> > ... 'LINE2': gpiod.LineSettings(direction=gpiod.line.Direction.OUTPUT, active_low=True,
> > ... output_value=gpiod.line.Value.ACTIVE),
> > ... }
> > ... )
> > >>> lr._name_map
> > {'LINE2': 2}
> > >>> lr.set_value('LINE0', gpiod.line.Value.ACTIVE)
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in <module>
> > File ".../gpiod/line_request.py", line 126, in set_value
> > self.set_values({line: value})
> > File ".../gpiod/line_request.py", line 138, in set_values
> > mapped = {
> > ^
> > File ".../gpiod/line_request.py", line 139, in <dictcomp>
> > self._name_map[line] if self._check_line_name(line) else line: values[line]
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > File ".../gpiod/line_request.py", line 82, in _check_line_name
> > raise ValueError("unknown line name: {}".format(line))
> > ValueError: unknown line name: LINE0
> >
>
> Rather than including example code and the error, put this, or similar, in a
> test case to both demonstrate the problem and the correctness of the fix.
>
> And, as well as describing the problem, you should describe what the fix
> is that you have implemented.
>
> The change itself looks ok to me.
>
Oh, and wrt the subject, the problem isn't specific to set_value() is it?
Any function using the line name to identify the line would fail too,
right?
Cheers,
Kent.
next prev parent reply other threads:[~2024-06-25 11:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 1:15 [libgpiod][PATCH] bindings: python: fix LineRequest.set_value only works for the last entry chuang+git
2024-06-25 10:53 ` Kent Gibson
2024-06-25 11:09 ` Kent Gibson [this message]
2024-06-25 12:32 ` Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240625110951.GB71664@rigel \
--to=warthog618@gmail.com \
--cc=brgl@bgdev.pl \
--cc=chuang+git@melty.land \
--cc=git@chuang.cz \
--cc=linux-gpio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.