Question

Ok, so, I might be missing the plot a bit here, but would really like some help. I am quite new to development etc. and have now come to a point where I need to implement DBus (or some other inter-program communication). I am finding the concept a bit hard to understand though.

My implementation will be to use an HTML website to change certain variables to be used in another program, thus allowing for the program to be dynamically changed in its working. I am doing this on a raspberry PI using Raspbian. I am running a webserver to host my website, and this is where the confusion comes in.

As far as I understand, DBus runs a service which allows you to call methods from a program in another program. So does this mean that my website needs to run a DBUS service to allow me to call methods from it into my program? To complicate things a bit more, I am coding in Python, so I am not sure if I can run a Python script on my website that would allow me to run a DBUS service. Would it be better to use JavaScript?

For me, the most logical solution would be to run a single DBUS service that somehow imports method from different programs and can be queried by others who want to run those methods. Is that possible?

Help would be appreciated! Thank you in advance!

Was it helpful?

Solution 2

This sounds like you should write an isolated D-Bus service to act as a datastore, and communicate synchronously with it in your scripts to write and read values. You can use shelve to persist the values between service invocations.

In the tutorial, the "Making method calls" section covers synchronous calls, and "Exporting objects" covers writing most of the D-Bus service.

OTHER TIPS

  • So does this mean that my website needs to run a DBUS service to allow me to call methods from it into my program?

A dbus background process (a daemon) would run on your web server, yes. In fact dbus provides two daemons. One is a system daemon which permits objects to receive system information (e.g. printer availability for exampple) and the second is a general user application to application IPC daemon. It is the second daemon that you definitely use for different applications to communicate.

  • I am coding in Python, so I am not sure if I can run a Python script on my website that would allow me to run a DBUS service.

There is no problem using python; dbus has bindings for many languages (e.g Java, perl, ruby, c++, Python). dbus objects can be mapped to python objects.

  • the most logical solution would be to run a single DBUS service that somehow imports method from different programs and can be queried by others who want to run those methods. Is that possible?

Correct - dbus provides a mechanism by which a client process will create dbus object or objects which allow that process to other services to other dbus-aware processes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top