On Wed, Jul 27, 2022 at 02:53:19PM +0530, Viresh Kumar wrote: > On 27-07-22, 10:58, Kent Gibson wrote: > > On Fri, Jul 08, 2022 at 05:04:58PM +0530, Viresh Kumar wrote: > > > diff --git a/bindings/rust/examples/gpioset.rs b/bindings/rust/examples/gpioset.rs > > > + let rconfig = RequestConfig::new().unwrap(); > > > + rconfig.set_consumer(&args[0]); > > > + rconfig.set_offsets(&offsets); > > > + > > > + chip.request_lines(&rconfig, &config).unwrap(); > > > > Wait rather than exiting immediately? > > Wait for what exactly ? > For long enough for the user to check that the line is set, as there is the possibility that when the line is released it will be set back to its default value and you will get users reporting that your set doesn't work ;-). So wait for a keypress? > > And, as mentioned elsewhere, add a gpiowatch example. > > Will do, sure. Any existing example of the same will help though. > There is an example in my proposed tool changes for v2[1]. It is very similar to gpiomon, just on the chip and with line info instead of edge events. Though that example is more complicated than you need as it supports named lines and operating over multiple chips. Hopefully you can see past that. The basic operation is watch the line, then wait for the chip fd to be readable and read the info changed event from it. You would only unwatch if you no longer had an interest in the line, which I expect will be the case in the D-BUS daemon that Bart has suggested. Cheers, Kent. [1]https://lore.kernel.org/linux-gpio/20220708120626.89844-5-warthog618@xxxxxxxxx/