Hi Bartosz, Thanks for the response, it is greatly appreciated. I've added a few comments below. On Fri, Mar 6, 2020 at 6:50 AM Bartosz Golaszewski <brgl@xxxxxxxx> wrote: > > czw., 5 mar 2020 o 15:57 Mark Deneen <mdeneen@xxxxxxxxx> napisał(a): > > > > Is it possible to use gpiod_line_request to set a given line as an > > output but retain the current state of the line? I can not use > > gpiod_line_get_value to query the state since the line in question has > > not been requested yet. > > No, because it doesn't make sense. If you're driving the line, you > define its state. I can test this, but does the line state reset when the chip is closed? > > > > Let's say that I have a userspace process which sets a gpio to high > > and I restart the process. I would like for the output to remain high > > when I request the line again in the new process. This was possible > > with gpiolib+sysfs, is it possible with libgpiod? > > > > This was rather a side effect of sysfs keeping the line exported > without any user-space process controlling it. This is not the case > with a character device where if the process exits, all resources are > freed ie. GPIOs are tied to processes rather than to a sysfs > interface. I understand. For some purposes this is a step backward although it is definitely far more deterministic and that's probably a good thing. Let's say, for example, that a GPIO output is connected to a circuit which controls a relay. My process initialzes this gpio and engages the relay. At some point this process is restarted, possibly due to a new version of the software being installed, and I wish for the relay to remain engaged during this operation. I can do this with the sysfs interface by initializing the state to a predetermined value if the direction had not been set to output yet. With libgpiod I would have to record the last state of the gpio somewhere and use this value when requesting the line. Should I be writing a kernel module instead of using libgpiod if I need this sort of control?