[Toybox] [PATCH] gpiod: new commands.

Rob Landley rob at landley.net
Tue Feb 22 04:10:49 PST 2022


On 2/21/22 7:17 PM, enh via Toybox wrote:
> Equivalent to the content of the gpiod debian package. Very different
> interface to the traditional Raspberry Pi command, but that command
> explicitly calls itself deprecated and tells you to use the gpiod
> package's commands instead.
> 
> "Works for me" on a Raspberry Pi 400, with a (small) variety of things
> connected to GPIOs as inputs and outputs.
>
> Missing gpiomon, which -- since the rest of these are about a year old
> at this point -- it doesn't look like I'm going to get around to writing
> any time soon unless someone asks for it...

Cool, and applied.

Hmmm, since you've been using it for a year and it looked OK I put it straight
into "other" instead of pending, but what is:

USE_GPIOFIND(NEWTOY(gpioinfo, "", TOYFLAG_USR|TOYFLAG_BIN))

Trying to accomplish with the ""? Can that be a 0 or is there a side effect you
need?

The reason gpiodetect segfaults when run on my laptop is because there are zero
chips detected (unsurprisingly), and llist_free_arg() is the callback called
from llist_traverse so calling it directly on NULL tries to dereference ->arg
because it assumes there is one. (And it wouldn't free the list anyway, that's
what the traverse is for.)

The only GPS device I have here is the j-core one we wrote ourselves from
scratch (https://github.com/j-core/gnss-baseband) handling the radio part of it
and everything with a userspace program (I had to learn what a leibnitz
transform was), and we haven't got a proper Linux driver that wires it up the
right way for these ioctls to work. (We never actually implemented the serial
protocol. I wasn't actually aware of these ioctls before this, back when Eric
was writing gpiod it did most of this stuff in userspace I think? The initial
reason for the daemon was so multiple programs could share a device, and so it
could cache the fix rather than waiting for the next report packet through the
serial interface. We actually worked out some of the design in long phone calls,
but I stopped being able to work with Eric a dozen years ago and haven't kept up
with this since...)

Anyway, that means I haven't got any way to test significant changes to this.
(Wanna use dlist_add() to create the list, wanna store an int instead of a
string in the data element, wanna have foreach_chip() do the open and pass in
the filehandle since none of the callbacks use the name for anything else...)

I may checkin a fix and poke you to tell me if I broke anything. :)

Query: do people actually say "gpiochip2" on the command line instead of just
the number? Not 100% certain why that capability is there in open_chip(), it's
only called with command line argument strings?

Rob



More information about the Toybox mailing list