You want to do something new with IoT, RFID ?. Drop me a message :).

Saturday, January 17, 2015

D-BUS example

D-BUS is a framework developed for IPC method (inter-process communication) in Linux. Below is a example for how to setup, implement and build an application using gdbus.
1. Environment setup:

- This example is written on Ubuntu 64bit. Run command below to install glib if it isn't installed:

a pkg-config --cflags glib-2.0
sudo apt-get install libglib2.0-dev

- Copy and unzip attached file here to your Home directory in Ubuntu. There are 3 folders in zip file as in picture below.

2. Code generation

In shell, go to directory gdbus_gen and run command make clean to cleanup generated file and run again command make to generate d-bus library. D-bus interface is declared in file blog.letrungthang.Example.Interface.xml. gdbus-codegen is a tool that will read xml file and generate d-bus library.

After generation file, in folder gdbus_gen you will get which will be used in both server and client application as in next sessions.

3. Eclipse setup, import, build and run project.

You only need to import 2 example projects zD-BUS_Client and zD-BUS_Server to Eclipse and build it. The light blue is generated files.

If you get error during build, you might need check in Eclipse configuration.

Build again and run both projects in Eclipse to see the result. Idea is that the server implements 2 timers to emit 2 signals periodically. Once the client receives signal from server , it will call method in server.

Happy new year 2015!!!

1 comment:

ramkumar said...

Thanks for sharing your experience and keep open for all