YUN Bridge on linux side should support IPC

26 views
Skip to first unread message

Vladislav Erochtchenkov

unread,
Sep 21, 2015, 3:19:04 AM9/21/15
to Developers
Hello all.

I'm developing some project where i have use daemon on the linux side which are recieving messages from AVR.
The problem is the communication speed because bridgeclient.py library can communicate with bridge server only through sockets (JSONServer on 5700 port).
But if the client application is located on the same OpenWRT system it is easy and better to use Shared Memory between two and more processes. It's called InterProcess Communication.

So, you keep JSONServer as is but add also sharing key/value pairs into IPC shared memory. It will improve communication between bridge <-> bridgeclint.py or bridge <-> bridgeclient.php
because it will not open and close sockets connections.

Please answer what are you thinking about it?

regards,
Vladislav
 

Federico Fissore

unread,
Sep 21, 2015, 3:23:28 AM9/21/15
to devel...@arduino.cc
I don't know how to establish a IPC when two processes have no
parent-child relationships, as it is for Bridge (which is started by the
AVR) and bridgeclient (which is part of your app)
If you can point me to some docs/examples, I'll be happy to read them.

However, you don't need to open/close sockets all the time.
bridgeclient_example.py contains this snippet that shows how you can
control when socket gets opened and closed

https://github.com/arduino/YunBridge/blob/master/bridge/bridgeclient_example.py#L42-L50

Regards

Federico

Andrew Kroll

unread,
Sep 21, 2015, 4:13:44 AM9/21/15
to devel...@arduino.cc

IPCs are awesome, fast, and save on RAM. I used them in the past for triggering audio events in the Linux DooM engine that I enhanced... one example on savings is the simple fact that the original code could only handle 8 or 16 audio events at once, but with IPC it handled 256-- I cut it at that because there was never > 256 events ever. This was way back on 20MHz 386's, which are pretty weak. If you want, I can dig up the old tarball for you to have a look at how to implement IPCs.

--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.

Federico Fissore

unread,
Sep 21, 2015, 4:49:55 AM9/21/15
to devel...@arduino.cc
Andrew Kroll ha scritto il 21/09/2015 alle 10:13:
> IPCs are awesome, fast, and save on RAM. I used them in the past for
> triggering audio events in the Linux DooM engine that I enhanced... one
> example on savings is the simple fact that the original code could only
> handle 8 or 16 audio events at once, but with IPC it handled 256-- I cut
> it at that because there was never > 256 events ever. This was way back
> on 20MHz 386's, which are pretty weak. If you want, I can dig up the old
> tarball for you to have a look at how to implement IPCs.


I'll be grateful. Just remind that I know how to implement it when a
process starts another process, because then I have a handle to the
child process
I don't know how to make this when the two processes know nothing about
each other

Federico

Andrew Kroll

unread,
Sep 21, 2015, 5:01:48 AM9/21/15
to devel...@arduino.cc

IPCs use something similar to socket port numbers. It may take a while to locate the tarball, it should be in an archive somewhere on an old harddisk or backup tape.

Andrew Kroll

unread,
Sep 21, 2015, 5:15:32 AM9/21/15
to devel...@arduino.cc
Found it on one of my backup servers, moved it to my web server.
Here is a link to the tarball:
http://dr.ea.ms/~oldfart/ajkdoom.tgz

--
Visit my github for awesome Arduino code @ https://github.com/xxxajk

Vladislav Erochtchenkov

unread,
Sep 21, 2015, 8:13:36 AM9/21/15
to devel...@arduino.cc
Federico,
I used IPC for intercommunication on C++ but there is also library for Python - https://docs.python.org/2/library/ipc.html

There are many ways for IPC: signal, sockets, semaphores, files, messages.
I suggest to use three ways:
- named pipe (easy to operate with)
- shared memory (low level access)
- semaphores (uses for blocking read/write between processes)

Here is i found cool example on python:

I have test it - it is working well. I have also attached it.
Hope it will help!

regards,
Vladislav

P.S. named pipe is very powerful solution and can be used easly on httpd (you just need to reate descriptor) or with SQLdb access - link db to pipe.

a.py
b.py
Reply all
Reply to author
Forward
0 new messages