linux D Bus tutorial
http://dbus.freedesktop.org/doc/dbus-tutorial.html
D-Bus Tutorial
Havoc
Pennington
Red Hat, Inc.
<hp@pobox.com
>
David
Wheeler
John
Palmieri
Red Hat, Inc.
<johnp@redhat.com
>
Colin
Walters
Red Hat, Inc.
<walters@redhat.com
>
Version 0.5.0
Table of Contents
Tutorial Work In Progress
What is D-Bus?
D-Bus applications
Concepts
Native Objects and Object Paths
Methods and Signals
Interfaces
Proxies
Bus Names
Addresses
Big Conceptual Picture
Messages - Behind the Scenes
Calling a Method - Behind the Scenes
Emitting a Signal - Behind the Scenes
Introspection
GLib API: Using Remote Objects
D-Bus - GLib type mappings
A sample program
Program initalization
Understanding method invocation
Connecting to object signals
Error handling and remote exceptions
More examples of method invocation
Generated Bindings
GLib API: Implementing Objects
Server-side Annotations
Python API
Qt API: Using Remote Objects
Qt API: Implementing Objects
Tutorial Work In Progress
This tutorial is not complete; it probably contains some useful information, but
also has plenty of gaps. Right now, you'll also need to refer to the D-Bus specification,
Doxygen reference documentation, and look at some examples of how other apps use D-Bus.
Enhancing the tutorial is definitely encouraged - send your patches or suggestions to the
mailing list. If you create a D-Bus binding, please add a section to the tutorial for your
binding, if only a short section with a couple of examples.
What is D-Bus?
D-Bus is a system for interprocess communication
(IPC). Architecturally, it has several layers:
A library, libdbus
, that allows two
applications to connect to each other and exchange messages.
A message bus daemon
executable, built on
libdbus, that multiple applications can connect to. The daemon can
Ïà¹ØÎĵµ£º
ʹÓùý³ÌÖеÄÐĵãº
Ò»¡¢½â³ýĿ¼ӳÉä¹Øϵ
umount Ŀ¼¿ÉÒÔ½â³ý¹ØÁª¹Øϵ
±ØÐëÏÈÔÚ¿Í»§¶Ëumount£¬È»ºóÔÚ·þÎñÆ÷¶ËÍ£Ö¹nfs·þÎñ£¬ÒÔ¼°ÐÞ¸Ä/etc/exports£¬·ñÔòµÄ»°»áµ¼ÖÂdf -hÎÞ·¨¹Ø±Õ
¶þ¡¢mount.nfs: Input/output error
½â¾ö:ÔÚ¿Í»§¶ËÒ²ÐèÆô¶¯portmap
Èý¡¢ÐÞ¸ÄÍê±Ï/etc/exportsÎļþÖ®ºó£¬¿ÉÒÔÖØÆônfs·þÎñ£¬Ò²¿ÉÒÔʹÓÃexp ......
ÎÒÕýÔÚѧϰдlinux device driver for embedded system.
ÎÒÓÐÒ»¸ölinuxǶÈëʽÉ豸£¬Ò²ÓÐÕâ¸öÉ豸µÄlinuxÔ´´úÂë¡£Ò²ÓÐcross compiler tool chain.
µÚÒ»²½£¬¾ÍÊÇдһ¸ö¼òµ¥µÄhelloÄ£¿é£¬È»ºó×°µ½É豸ÖС£ÒÔÑéÖ¤ÎÒÕâ¸ö¿ª·¢»·¾³¡£
ÔÚÍøÉÏËÑË÷ÁËһϣ¬ how to cross compile linux device driver
·¢ÏÖÔÚlinux´úÂë¸ùĿ¼µÄMak ......
Ŀ¼ºÍÎļþ²Ù×÷
²é¿´µ±Ç°Ä¿Â¼Ïà¶ÔÓÚ¸ùĿ¼µÄλÖÃ
¡¡
¡¡¡¡pwd
²é¿´µ±Ç°Ä¿Â¼ÄÚÈÝ
¡¡¡¡ls
ÒÔ³¤¸ñʽ²é¿´µ±Ç°Ä¿Â¼ÄÚÈÝ¡£¶ÔӦÿ¸öÎļþµÄÌõÄ¿½«°üÀ¨Á¬½ÓÊýÄ¿¡¢ËùÓÐÕß¡¢´óС¡¢×îºóÐÞ¸Äʱ¼ä¡¢È¨ÏÞµÈÄÚÈÝ
¡¡¡¡ls -l
¸Ä±äµ±Ç°Ä¿Â¼¡£Ä¿µÄĿ¼Ãû¿ÉÓÃÏà¶Ô·¾¶±íʾ£¬Ò²¿ÉÒÔÓþø¶Ô·¾¶±íʾ¡£
cd [Ä¿µÄĿ¼Ãû]
תÒƵ½ÉÏÒ»¼¶Ä¿Â¼
c ......
ÔÚijЩÌØÊâµÄÇé¿öÏ£¬ÈçÒòΪÍøÂç»òÕßXÅäÖõĹØϵÎÞ·¨Á¬½Óµ½X server»òÕßÖ÷»úÉÏûÓÐX£¬¾Í¿ÉÒÔʹÓþ²Ä¬°²×°µÄ·½Ê½°²×°Êý¾Ý¿â£¬Í¬ÑùÈç¹ûÐèÒª´ó¹æÄ£²¿Êð£¬Ôò¾²Ä¬°²×°½«»á´ó´ó¼õÇáDBAµÄÖظ´ÀͶ¯Á¦£¬¶øÇÒ¾²Ä¬°²×°²»ÐèÒªX£¬´Ó°²×°Ð§ÂÊ
ÔÚijЩÌØÊâµÄÇé¿öÏ£¬ÈçÒòΪÍøÂç»òÕßXÅäÖõĹØϵÎÞ·¨Á¬½Óµ½X server»òÕßÖ÷»úÉÏûÓÐX£ ......
ÔÚVFSµÄÖ§³ÖÏ£¬Óû§Ì¬½ø³Ì¶ÁдÈκÎÀàÐ͵ÄÎļþϵͳ¶¼¿ÉÒÔʹÓÃreadºÍwrite×ÅÁ½¸öϵͳµ÷Ó㬵«ÊÇÔÚlinuxÄÚºËÖÐûÓÐÕâÑùµÄϵͳµ÷ÓÃÎÒÃÇÈçºÎ²Ù×÷ÎļþÄØ£¿ÎÒÃÇÖªµÀreadºÍwriteÔÚ½øÈëÄÚºË̬֮ºó£¬Êµ¼ÊÖ´ÐеÄÊÇsys_readºÍsys_write£¬µ«ÊDz鿴ÄÚºËÔ´´úÂ룬·¢ÏÖÕâЩ²Ù×÷ÎļþµÄº¯Êý¶¼Ã»Óе¼³ö(ʹÓÃEXPORT_SYMBOLµ¼³ö)£¬Ò²¾ÍÊÇ˵ÔÚÄÚºË ......