Using dbus in embedded Linux

Dan

The dbus communication interface in Linux systems manages most system level information or control. Desktops need to know how to manage things like USB drive insertion or WiFi settings. This lead to dbus (short for desktop bus), but quickly became core to all system management. For example, it controls the following items:

* WiFi connections (including password prompts)
* Battery level and charging status
* USB storage or speakers
* Bluetooth (including pairing, speakers, and telephones)
* Available package upgrades
* System sleep, shutdown, or reboot

So why would you want embedded systems to know about dbus? Most of the things listed above are still needed in an embedded device, but there isn’t a desktop to display them on. You want to be able to manage those things yourself so that the computer inside is invisible.

Let’s talk about what dbus is and how it does it’s job

Dbus is an Inter Process Communication protocol (IPC). It allows multiple processes to exchange information in a standardized way. This is typically used to separate the back end system control from the user facing interface. For example, a product specific process could manage WiFi connections in a different way than the typical network icon.

IPCs have been around on operating systems for quite some time. On Windows, COM and DDE are probably the best known. On MacOS, Distributed Notifications or AppleEvents are good examples. You can run dbus on any modern Unix, Windows, or MacOS platform; but it’s only the standard system management IPC on Linux.

The Dbus protocol defines both how to exchange data, and also the metadata about what data is available. This ensures that processes aren’t trying to communicate with incompatible service definitions. This also allows introspection of the services and tracing of message traffic for development.

Because the protocol is the standard, the exact version of the processes doesn’t matter. As long as they follow the standard interface, everything works. This makes it easy to do security upgrades and to substitute product specific interfaces. Dbus packages are available for any modern language. The reference dbus implementation is in C and many languages just wrap that. Native implementations are also possible.

You need a security model for systems management

The security model insures that the wrong users (or roles in the embedded case) aren’t doing something inappropriate. Because dbus is limited to a single machine, it can rely on the operating system to tell it who it is talking to and what groups they are in. With that information, the security policy can be easily defined for any service.

There are usually two dbus instances running on a Linux system: system and session. The session dbus is created when you login and is isolated to processes run within that login. This lets you do things like copy-and-paste, for example. You don’t usually need any additional security in the session bus.

The system bus manages things like shutdown and networks. It can define what operations are permitted depending on the remote connection’s user or group. For an embedded system, there may be no point in having a session bus and everything may be controlled through the system bus.

Do you need dbus?

There are command line programs for most system management functions. However, these traditional interfaces now talk dbus to get the job done. For example, the shutdown command actually uses dbus to tell systemd to set a new run level. Talking directly to dbus saves a step and may expose a richer interface than the command line.

Once you are interacting with dbus, then all your system management can be done in a product specific way. The well tested Linux back end processes are doing the work, but are controlled through your product specific policies or user interface.

Links

* https://www.freedesktop.org/wiki/Software/dbus/
* https://www.freedesktop.org/wiki/Software/DBusBindings/
* https://en.wikipedia.org/wiki/D-Bus
* https://github.com/GNOME/d-feet
* https://github.com/freedesktop/bustle
* https://pypi.org/project/pydbus/
* https://github.com/Gekoncze/ExamplesPydbus

Categories: Uncategorized

Cardinal Peak
Learn more about our Audio & Video capabilities.

Dive deeper into our IoT portfolio

Take a look at the clients we have helped.

We’re always looking for top talent, check out our current openings. 

Contact Us

Please fill out the contact form below and our engineering services team will be in touch soon.

We rely on Cardinal Peak for their ability to bolster our patent licensing efforts with in-depth technical guidance. They have deep expertise and they’re easy to work with.
Diego deGarrido Sr. Manager, LSI
Cardinal Peak has a strong technology portfolio that has complemented our own expertise well. They are communicative, drive toward results quickly, and understand the appropriate level of documentation it takes to effectively convey their work. In…
Jason Damori Director of Engineering, Biamp Systems
We asked Cardinal Peak to take ownership for an important subsystem, and they completed a very high quality deliverable on time.
Matt Cowan Chief Scientific Officer, RealD
Cardinal Peak’s personnel worked side-by-side with our own engineers and engineers from other companies on several of our key projects. The Cardinal Peak staff has consistently provided a level of professionalism and technical expertise that we…
Sherisse Hawkins VP Software Development, Time Warner Cable
Cardinal Peak was a natural choice for us. They were able to develop a high-quality product, based in part on open source, and in part on intellectual property they had already developed, all for a very effective price.
Bruce Webber VP Engineering, VBrick
We completely trust Cardinal Peak to advise us on technology strategy, as well as to implement it. They are a dependable partner that ultimately makes us more competitive in the marketplace.
Brian Brown President and CEO, Decatur Electronics
The Cardinal Peak team started quickly and delivered high-quality results, and they worked really well with our own engineering team.
Charles Corbalis VP Engineering, RGB Networks
We found Cardinal Peak’s team to be very knowledgeable about embedded video delivery systems. Their ability to deliver working solutions on time—combined with excellent project management skills—helped bring success not only to the product…
Ralph Schmitt VP, Product Marketing and Engineering, Kustom Signals
Cardinal Peak has provided deep technical insights, and they’ve allowed us to complete some really hard projects quickly. We are big fans of their team.
Scott Garlington VP Engineering, xG Technology
We’ve used Cardinal Peak on several projects. They have a very capable engineering team. They’re a great resource.
Greg Read Senior Program Manager, Symmetricom
Cardinal Peak has proven to be a trusted and flexible partner who has helped Harmonic to deliver reliably on our commitments to our own customers. The team at Cardinal Peak was responsive to our needs and delivered high quality results.
Alex Derecho VP Professional Services, Harmonic
Yonder Music was an excellent collaboration with Cardinal Peak. Combining our experience with the music industry and target music market, with Cardinal Peak’s technical expertise, the product has made the mobile experience of Yonder as powerful as…
Adam Kidron founder and CEO, Yonder Music
The Cardinal Peak team played an invaluable role in helping us get our first Internet of Things product to market quickly. They were up to speed in no time and provided all of the technical expertise we lacked. They interfaced seamlessly with our i…
Kevin Leadford Vice President of Innovation, Acuity Brands Lighting
We asked Cardinal Peak to help us address a number of open items related to programming our systems in production. Their engineers have a wealth of experience in IoT and embedded fields, and they helped us quickly and diligently. I’d definitely…
Ryan Margoles Founder and CTO, notion