Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using libgpiod how do I switch direction of a requested line on the fly?

Tags:

c++

linux

gpio

I'm rewriting my code, changing from sysfs interface forward to libgpiod. After the request of a line, direction is fixed and I need to figure out, how to switch the direction of this line on the fly for changing between input and output. At the moment I don't see the right way, and a further request is denied.

When I do a cycle of request - use - release - request-again with different direction, this seem wrong overhead to me.

I would prefer to have a function call, which changes the direction from in to out and vice versa.

Is there something, I've overseen?

like image 283
Jo Luxer Avatar asked Oct 25 '25 19:10

Jo Luxer


1 Answers

Answering the question myself:

The direction is currently not changeable yet without releasing the line.

I've got this directly from the author of libgpiod via e-mail:

... this is because the kernel doesn't allow to change the direction without releasing a line. This however will change in linux v5.5 as the patches introducing this functionality have been reviewed and are pending a merge. New version of libgpiod with support for that will be released shortly after.

Best regards, Bartosz Golaszewski

like image 110
Jo Luxer Avatar answered Oct 28 '25 09:10

Jo Luxer