linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [libgpiod]
       [not found] ` <BN7PR13MB25322B3D67DFC0E8787E79C6DE140@BN7PR13MB2532.namprd13.prod.outlook.com>
@ 2019-07-11  9:02   ` Bartosz Golaszewski
  2019-07-11 14:55     ` [libgpiod] Kevin Welsh
  0 siblings, 1 reply; 4+ messages in thread
From: Bartosz Golaszewski @ 2019-07-11  9:02 UTC (permalink / raw)
  To: Kevin Welsh; +Cc: linux-gpio

pon., 3 cze 2019 o 14:24 Kevin Welsh <kwelsh@welshtechnologies.com> napisał(a):
>
> I am trying to make gpiomon into a daemon using busybox. (start-stop-daemon -b) Instead of writing a message to stdout, I need it to execute a script. My use case is that I need a button press (gpio) to undo setting a static IP.
>
> If I set - -format="touch buttton-was-pressed|sh"
>
> Is this a valid command to make into a daemon? If not, can I submit a patch to include a parameter for executing a script?

Hi Kevin,

I didn't see this message because you didn't Cc me personally.

Yes your example would work i.e. gpiomon would print this string on a
GPIO event. Executing scripts is on my TODO list, but your
contribution will be more than welcome. :)

Best regards,
Bartosz Golaszewski

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [libgpiod]
  2019-07-11  9:02   ` [libgpiod] Bartosz Golaszewski
@ 2019-07-11 14:55     ` Kevin Welsh
  0 siblings, 0 replies; 4+ messages in thread
From: Kevin Welsh @ 2019-07-11 14:55 UTC (permalink / raw)
  To: Bartosz Golaszewski; +Cc: linux-gpio

[-- Attachment #1: Type: text/plain, Size: 1160 bytes --]

Hello Bartosz,

Thanks for the reply.

I did work out a simple patch to get what I needed. It's attached in case it's of any use.


Kevin

-----Original Message-----
From: Bartosz Golaszewski <brgl@bgdev.pl> 
Sent: Thursday, July 11, 2019 5:02 AM
To: Kevin Welsh <kwelsh@welshtechnologies.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [libgpiod]

pon., 3 cze 2019 o 14:24 Kevin Welsh <kwelsh@welshtechnologies.com> napisał(a):
>
> I am trying to make gpiomon into a daemon using busybox. (start-stop-daemon -b) Instead of writing a message to stdout, I need it to execute a script. My use case is that I need a button press (gpio) to undo setting a static IP.
>
> If I set - -format="touch buttton-was-pressed|sh"
>
> Is this a valid command to make into a daemon? If not, can I submit a patch to include a parameter for executing a script?

Hi Kevin,

I didn't see this message because you didn't Cc me personally.

Yes your example would work i.e. gpiomon would print this string on a GPIO event. Executing scripts is on my TODO list, but your contribution will be more than welcome. :)

Best regards,
Bartosz Golaszewski

[-- Attachment #2: 0001-add-script.patch --]
[-- Type: application/octet-stream, Size: 1726 bytes --]

diff --git a/src/tools/gpiomon.c b/src/tools/gpiomon.c
index c13ab38..0409b70 100644
--- a/src/tools/gpiomon.c
+++ b/src/tools/gpiomon.c
@@ -27,10 +27,11 @@ static const struct option longopts[] = {
 	{ "rising-edge",	no_argument,		NULL,	'r' },
 	{ "falling-edge",	no_argument,		NULL,	'f' },
 	{ "format",		required_argument,	NULL,	'F' },
+	{ "script",		required_argument,	NULL,	'S' },
 	{ GETOPT_NULL_LONGOPT },
 };
 
-static const char *const shortopts = "+hvln:srfF:";
+static const char *const shortopts = "+hvln:srfF:S:";
 
 static void print_help(void)
 {
@@ -47,6 +48,7 @@ static void print_help(void)
 	printf("  -r, --rising-edge:\tonly process rising edge events\n");
 	printf("  -f, --falling-edge:\tonly process falling edge events\n");
 	printf("  -F, --format=FMT\tspecify custom output format\n");
+	printf("  -S, --script=SCT\tspecify script to run upon completion\n");
 	printf("\n");
 	printf("Format specifiers:\n");
 	printf("  %%o:  GPIO line offset\n");
@@ -62,6 +64,7 @@ struct mon_ctx {
 
 	bool silent;
 	char *fmt;
+	char *sct;
 
 	int sigfd;
 };
@@ -212,8 +215,10 @@ static int event_callback(int event_type, unsigned int line_offset,
 		return GPIOD_CTXLESS_EVENT_CB_RET_OK;
 	}
 
-	if (ctx->events_wanted && ctx->events_done >= ctx->events_wanted)
+	if (ctx->events_wanted && ctx->events_done >= ctx->events_wanted) {
+		system(ctx->sct);
 		return GPIOD_CTXLESS_EVENT_CB_RET_STOP;
+	}
 
 	return GPIOD_CTXLESS_EVENT_CB_RET_OK;
 }
@@ -281,6 +286,9 @@ int main(int argc, char **argv)
 		case 'F':
 			ctx.fmt = optarg;
 			break;
+		case 'S':
+			ctx.sct = optarg;
+			break;
 		case '?':
 			die("try %s --help", get_progname());
 		default:

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [libgpiod]
  2020-02-10 10:46 ` [libgpiod] Geoffrey White
@ 2020-02-10 14:30   ` Bartosz Golaszewski
  0 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2020-02-10 14:30 UTC (permalink / raw)
  To: Geoffrey White; +Cc: open list:GPIO SUBSYSTEM

pon., 10 lut 2020 o 11:46 Geoffrey White <geoffrey@geoffrey.id.au> napisał(a):
>
> Hello,
>
> What a great library gpiod is. I am trying to port over my robot
> software from WiringPi to it at the moment.  I am running Ubuntu 18.04
> on both a development laptop and a Raspbery Pi 3 A+. I cross compile
> version 1.4.2 and can run on the Pi and iterate over the detected
> devices fine. However I'm not able to detect the correct chipset on
> the device.
>
> The Pi v3a+ uses the Broadcom chipset BCM2837B0, however the chip is
> detected as a bcm2835 which is from the original Pi v1. Further, none
> of the lines are labelled with a description. They all appear as
> "unnamed" instead of labels such as  "GPIO_GCLK" or "GPIO17"
>

Hi!

I don't have an RPi3A+ (or any RPi for that matter) but just a quick
look at the relevant device tree in upstream kernel is telling me that
the compatible used for the GPIO controller is "brcm,bcm2835-gpio" for
which the driver should introduce itself as "pinctrl-bcm2835". And
it's fine - maybe it's the same old pinctrl IP in the newer SoC?

As for the pin descriptions: libgpiod only extracts data provided by
the kernel and I have never received reports of this feature not
working before. I'd look for the problem in the kernel first. In
mainline linux I can see all the pins having names though.

Bartosz

> I heard the stock Kernel. on 18.04 (4.15) did have some issues,
> however I have since upgraded to the 5.3.0 Kernal on both my dev
> laptop and Pi.
>
> I would personally like to keep to using the Ubuntu distribution for
> the Pi, however perhaps it is better i revert back to Raspbian.
>
> My future work I hope to integrate the DMA timing for a simple PWM
> control using the gpiod, i'd like to help out with the project if I
> can, sorry if I have approached the wrong email list.
>
>  Regards,
>
> Geoffrey.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [libgpiod]
       [not found] <CADn0hExOJHS0OhU41sToXxqnqpyWjmCPrsVwXE-OKBLg-0dsRQ@mail.gmail.com>
@ 2020-02-10 10:46 ` Geoffrey White
  2020-02-10 14:30   ` [libgpiod] Bartosz Golaszewski
  0 siblings, 1 reply; 4+ messages in thread
From: Geoffrey White @ 2020-02-10 10:46 UTC (permalink / raw)
  To: linux-gpio

Hello,

What a great library gpiod is. I am trying to port over my robot
software from WiringPi to it at the moment.  I am running Ubuntu 18.04
on both a development laptop and a Raspbery Pi 3 A+. I cross compile
version 1.4.2 and can run on the Pi and iterate over the detected
devices fine. However I'm not able to detect the correct chipset on
the device.

The Pi v3a+ uses the Broadcom chipset BCM2837B0, however the chip is
detected as a bcm2835 which is from the original Pi v1. Further, none
of the lines are labelled with a description. They all appear as
"unnamed" instead of labels such as  "GPIO_GCLK" or "GPIO17"

I heard the stock Kernel. on 18.04 (4.15) did have some issues,
however I have since upgraded to the 5.3.0 Kernal on both my dev
laptop and Pi.

I would personally like to keep to using the Ubuntu distribution for
the Pi, however perhaps it is better i revert back to Raspbian.

My future work I hope to integrate the DMA timing for a simple PWM
control using the gpiod, i'd like to help out with the project if I
can, sorry if I have approached the wrong email list.

 Regards,

Geoffrey.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-10 14:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <BN7PR13MB2532728B9B6D7E73875DFCF1DE140@BN7PR13MB2532.namprd13.prod.outlook.com>
     [not found] ` <BN7PR13MB25322B3D67DFC0E8787E79C6DE140@BN7PR13MB2532.namprd13.prod.outlook.com>
2019-07-11  9:02   ` [libgpiod] Bartosz Golaszewski
2019-07-11 14:55     ` [libgpiod] Kevin Welsh
     [not found] <CADn0hExOJHS0OhU41sToXxqnqpyWjmCPrsVwXE-OKBLg-0dsRQ@mail.gmail.com>
2020-02-10 10:46 ` [libgpiod] Geoffrey White
2020-02-10 14:30   ` [libgpiod] Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).