Re: [libgpiod][PATCH] bindings: python: fix LineRequest.set_value only works for the last entry

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

 



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@xxxxxxxxxx wrote:
> > From: Chuang Zhu <git@xxxxxxxxx>
> >
> > 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.




[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