# Pass GPIO 'reference' between apps

**URL:** <https://forum.legato.io/t/pass-gpio-reference-between-apps/4123>\
**Category:** Legato Application Framework\
**Created:** [February 17, 2019, 11:10am UTC](https://forum.legato.io/t/pass-gpio-reference-between-apps/4123 "2019-02-17T11:10:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.legato.io/u/davidc)\
**Post date:** [February 17, 2019, 11:10am UTC](https://forum.legato.io/t/pass-gpio-reference-between-apps/4123/1 "2019-02-17T11:10:05Z")

</div>

Hiya,

Is it possible to pass a GPIO ‘reference’ of some sort between apps?

Use case

* * *

I have a generic service that can do ‘something’ to a unspecified GPIO (lets say toggle at a specified rate). This GPIO controller is exposed via an API.

I then want to set up two clients to use this API - each client uses a different GPIO (bound in the appropriate Component.cdef and app.adef) and I want to pass the ‘GPIO’ via API to the service.

Any thoughts?

ciao, Dave

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [February 17, 2019, 4:08pm UTC](https://forum.legato.io/t/pass-gpio-reference-between-apps/4123/2 "2019-02-17T16:08:12Z")

</div>

Why don’t you create a 3rd app to control all gpio?  
Your two apps can call the function of 3rd app when toogle gpio.

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.legato.io/u/davidc)\
**Post date:** [February 17, 2019, 11:16pm UTC](https://forum.legato.io/t/pass-gpio-reference-between-apps/4123/3 "2019-02-17T23:16:51Z")

</div>

Hi @jyijyi

Ta for your thoughts.

> [@jyijyi](#):
>
> Why don’t you create a 3rd app to control all gpio?

So, write a replacement service for the legato `gpio` service? I’m trying to re-use what is already available. Two layers of IPC is going to be pretty slow.

Actually, what I think I’ll do is act on the pins directly (using the `/sys` file interface) - then I can either pass the GPIO number through the service API, or even better, pass the open FD from the client into the service and act directly on the `/sys/` file. That way I can use the legato GPIO service to setup the GPIO, but save on the IPC time lag when operating on the GPIO.

ciao, Dave

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [February 17, 2019, 11:57pm UTC](https://forum.legato.io/t/pass-gpio-reference-between-apps/4123/4 "2019-02-17T23:57:06Z")

</div>

No, you need to keep the gpio service.  
What i mean is only using the 3rd app to call goio API, and the other two apps will use IPC to call 3rd app to control gpio.
