Re: GPIO Bulk Request Problem

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

 



Hi Bart,

On Wed, Sep 22, 2021 at 6:27 PM Kenneth Sloat <ksloat@xxxxxxxxxxxxxxxx> wrote:
>>
>> Hello,
>>
>> I am using libgpiod v1.4.1 and am having trouble using a bulk request of gpio lines as outputs from a chip. I am using the C++ bindings. I have confirmed that I can individually request lines and set them as expected. However, if I use the bulk request, while I get the expected number of lines (and defaulted value is set correctly), iterating through them (with array operator in this case) and trying to set the values is not working as expected. I find that for every index/position, line 0 is the one being toggled.
>>
>> A simple example is below:
>>
>>     gpiod::chip *mychip;
>>
>>     mychip = new gpiod::chip("1");

> Why would you need to allocate it with new?

It's just how I chose to throw the example together.

>>
>>     gpiod::line_bulk lines = mychip->get_all_lines();
>>     lines.request({std::string("gpio-test"),
>>         gpiod::line_request::DIRECTION_OUTPUT, 0});
>>
>>     for (unsigned int i = 0; i < lines.size(); i++) {
>>         printf("Set line %d\n", i);
>>         lines[i].set_value(1);
>>         usleep(1000 * 1000);
>>         printf("Clear line %d\n", i);
>>         lines[i].set_value(0);
>>         usleep(1000 * 1000);
>>         printf("\n");
>>     }
>>
>>     return 0;
>>
>> Not sure if this is a usage problem on my part or an actual issue.
>>

> I'll see if I can confirm the behavior here but it looks like a bug indeed.

> Bart

Thanks Bart. If you use individual requests to the GPIOs as outputs first, use can still use the index operator (or iterator) on a line_bulk object to individually set the LEDs. It doesn't work when you only use the request through this object though:
    gpiod::line_bulk lines = mychip->get_all_lines();
        lines.request(......

> Thanks
>
> Sincerely,
> Ken Sloat

Thanks

Sincerely,
Ken Sloat



[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