# Bidirectional IPC between apps

**URL:** <https://forum.legato.io/t/bidirectional-ipc-between-apps/5967>\
**Category:** Uncategorized\
**Created:** [September 17, 2021, 10:57pm UTC](https://forum.legato.io/t/bidirectional-ipc-between-apps/5967 "2021-09-17T22:57:59Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [September 17, 2021, 10:57pm UTC](https://forum.legato.io/t/bidirectional-ipc-between-apps/5967/1 "2021-09-17T22:57:59Z")

</div>

is there any way to have bidirectional communication between apps?  
APP1 is communicating with APP2 using APP2.API, but then I want APP2 to directly communicate with APP1 using APP1.API, is there any way to achieve this?  
It seems that when I cross the binding between apps, then both of them hang waiting for each other to start.

---

<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:** [September 18, 2021, 12:10am UTC](https://forum.legato.io/t/bidirectional-ipc-between-apps/5967/2 "2021-09-18T00:10:14Z")

</div>

Does this help?

> [@Cannot get callback between components (IPC) to work properly](https://forum.legato.io/t/cannot-get-callback-between-components-ipc-to-work-properly/4653):
>
> Hi, I’m currently working on an application that must send data from one component (component A) to the other (component B) (via IPC). The sending part is implemented via API in component B. communication.api FUNCTION send ( char buffer[BUFFER\_SIZE] IN ); However component B can have data ready at any time for component A. For this case I want to use a callback to send data from component B to component A. I tried the following: communication.api DEFINE BUFFER\_SIZE = 64; HANDLER o…

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [September 20, 2021, 5:07am UTC](https://forum.legato.io/t/bidirectional-ipc-between-apps/5967/3 "2021-09-20T05:07:24Z")

</div>

yes, it does help, but I want to pass more data through the handler and I was wondering what is the best way to do so.  
Should I create a REFERENCE and then to pass this as IN of the handler?  
Not sure what is the best course of actions in legato.

---

<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:** [September 20, 2021, 5:34am UTC](https://forum.legato.io/t/bidirectional-ipc-between-apps/5967/4 "2021-09-20T05:34:13Z")

</div>

how about using STRUCT with array:

> [@In legato 19.02 api is not supporting more than 2 string](https://forum.legato.io/t/in-legato-19-02-api-is-not-supporting-more-than-2-string/5716/2):
>
> how about making the API file like this? STRUCT ARRAY123 { string Array1[10]; int32 port1; string Array2[10]; int32 port2; string Array3[10]; int32 port3; string Array4[10]; int32 port4; string Array5[10]; int32 port5; }; FUNCTION arraySend ( ARRAY123 asd IN ); It is working on my side with vscode leaf swi-wp76\_4.7.0. You can use my code: [IPC\_step1.rar](https://forum.legato.io/uploads/short-url/dgUwkVXIXDa6sS6CbPxzjqn2x7a.rar) (2.4 KB)

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [September 20, 2021, 7:15am UTC](https://forum.legato.io/t/bidirectional-ipc-between-apps/5967/5 "2021-09-20T07:15:59Z")

</div>

yeah, I have seen that post, but I am wondering if is easier to define the struct on the .api file, or to use the REFERENCE and then to declare the struct in the .h file.

I still get an error for:  
/home/claudio/swi-telemation-development/Apps/Applications/IPC\_step4/loggerClient/loggerClient.c:80:26: error: parameter 1 (‘percentUsedSpace’) has incomplete type  
struct logger4\_Params\_t percentUsedSpace,

were I have modified as follow:  
STRUCT Params  
{  
uint32 command;  
//uint32 port1;  
};

HANDLER MsgFromServerHandler  
(  
Params value IN // IN: view from client point of view  
);

// For events from server

// Event callback

static void MsgFromServerHandler

(

struct logger4\_Params\_t percentUsedSpace,

void\* contextPtr

)

{

//LE\_INFO( PREFIX\_LOG\_MSG “async msg received from server; percent of buffer messages used = %u %%”, percentUsedSpace );

}

---

<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:** [September 20, 2021, 7:24am UTC](https://forum.legato.io/t/bidirectional-ipc-between-apps/5967/6 "2021-09-20T07:24:08Z")

</div>

I used STRUCT in api file and I remember it is working fine.

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [September 20, 2021, 7:47am UTC](https://forum.legato.io/t/bidirectional-ipc-between-apps/5967/7 "2021-09-20T07:47:29Z")

</div>

you have used the struct to pass over to the handler? because also in another couple of posts was mentioned that the api do no support struct so we were wondering if this is the proper way of doing it.

---

<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:** [September 20, 2021, 8:12am UTC](https://forum.legato.io/t/bidirectional-ipc-between-apps/5967/8 "2021-09-20T08:12:12Z")

</div>

only tried client to server in swi-wp76\_4.7.0 , not for server to client callback function.  
You might give a try.

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [September 20, 2021, 8:20am UTC](https://forum.legato.io/t/bidirectional-ipc-between-apps/5967/9 "2021-09-20T08:20:00Z")

</div>

we are just trying to replace the uint32\_t feedback on the handler with a struct, so we can pass back a more comprehensive information.  
It all compile fine, but it seems that the message event is not sent properly:  
logger\_server.c AsyncResponse\_logger\_AddMsgFromServerHandler() 446 | Assert Failed: ‘le\_pack\_PackReference( &\_msgBufPtr, value )’

---

<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:** [September 20, 2021, 8:24am UTC](https://forum.legato.io/t/bidirectional-ipc-between-apps/5967/10 "2021-09-20T08:24:27Z")

</div>

is it ok for passing STRUCT information from client to server

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [September 20, 2021, 8:30am UTC](https://forum.legato.io/t/bidirectional-ipc-between-apps/5967/11 "2021-09-20T08:30:03Z")

</div>

I have simplified the sample you have sent through and used a reference instead, would you be able to run it your end?  
[IPC\_step4.zip](https://forum.legato.io/uploads/short-url/6q6XdEyKG36QbjTFIjhDPXvNJ5t.zip) (237.5 KB)

---

<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:** [September 20, 2021, 8:48am UTC](https://forum.legato.io/t/bidirectional-ipc-between-apps/5967/12 "2021-09-20T08:48:47Z")

</div>

Are you running in swi-wp76\_4.7.0

Btw, is it ok to run in STRUCT with array

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [September 20, 2021, 8:55am UTC](https://forum.legato.io/t/bidirectional-ipc-between-apps/5967/13 "2021-09-20T08:55:00Z")

</div>

I have got it to work with the struct, but I am running it on WP77xx legato 19.11

---

<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:** [September 20, 2021, 9:03am UTC](https://forum.legato.io/t/bidirectional-ipc-between-apps/5967/14 "2021-09-20T09:03:14Z")

</div>

OK, then that is great, I also remember STRUCT is working fine with swi-wp76\_4.7.0  
i.e. WP76 (Release 13.3 + Legato 20.04.0)
