Changeset 40271 in project


Ignore:
Timestamp:
07/10/21 13:55:06 (3 weeks ago)
Author:
ecloud
Message:

links etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/dbus

    r40270 r40271  
    77=== Overview
    88
    9 This is a binding for libdbus 1.x.  D-Bus is a popular IPC (inter-process communication) protocol which is often used between system components (for example hald informs applications when new hardware becomes available, gpsd informs apps when the location has changed, or an application requests gsmd to place a phone call).
     9This is a binding for [[https://dbus.freedesktop.org/doc/api/html/index.html|libdbus]] 1.x.  [[https://www.freedesktop.org/wiki/Software/dbus/|D-Bus]] is a popular IPC (inter-process communication) protocol which is often used between system components (for example hald informs applications when new hardware becomes available, gpsd informs apps when the location has changed, or an application requests gsmd to place a phone call).
    1010
    1111=== Goals & status
     
    155155Provide a handler (a method body) to be called when the current
    156156process receives a D-Bus message which matches the given context and
    157 the given method name.  Start a SRFI-18 thread to poll for incoming
     157the given method name.  Start a [[http://wiki.call-cc.org/eggref/5/srfi-18|SRFI-18]] thread to poll for incoming
    158158messages (unless polling has been disabled on this bus).
    159159
     
    210210==== Examples you can test with [[https://en.wikipedia.org/wiki/Qt_(software)|Qt]]
    211211
    212 Qt includes a D-Bus remote-controlled car example.  E.g. it might be located in {{/usr/share/doc/qt6/examples/dbus/remotecontrolledcar}} depending on your distro.  If you run the car, you can cause the wheels of the car to turn to the right by doing this:
     212Qt includes a D-Bus [[https://doc.qt.io/qt-6/qtdbus-remotecontrolledcar-example.html|remote-controlled car example]].  E.g. it might be located in {{/usr/share/doc/qt6/examples/dbus/remotecontrolledcar}} depending on your distro.  If you run the car, you can cause the wheels of the car to turn to the right by doing this:
    213213
    214214<enscript highlight=scheme>
     
    255255{{register-method}} starts a polling loop the first time that it is called with a context specifying a particular bus.  (And if you register methods on multiple buses, there must be a polling thread for each.)  So you can then run the program above which does {{send}}, and you will see the appropriate printf statement execute asynchronously when the message is received.  However the polling thread is subject to the usual limitations of Chicken threads: if there is any blocking I/O, which is waiting for something, then all threads are blocked.  That means you should not use the readline egg for example, because the polling thread will be blocked between each time that you type something and hit Enter.
    256256
    257 If the polling thread doesn't work, and you would prefer to poll manually, you can call {{(enable-polling-thread! enable: #f)}} to stop the thread (or to prevent it from being started when you register a new method), and then call {{poll-for-message periodically}}.  Both of those functions can take an optional bus: parameter (which defaults to {{session-bus}}, naturally).  {{poll-for-message}} can also take an optional timeout: parameter (which is 0 by default, so that it is a non-blocking call).
     257If the polling thread doesn't work, and you would prefer to poll manually, you can call {{(enable-polling-thread! enable: #f)}} to stop the thread (or to prevent it from being started when you register a new method), and then call {{poll-for-message periodically}}.  Both of those functions can take an optional bus: parameter (which defaults to {{session-bus}}, naturally).  {{poll-for-message}} can also take an optional {{timeout:}} parameter (which is 0 by default, so that it is a non-blocking call).
    258258
    259259==== Examples based on the D-Bus Tutorial
     
    298298</enscript>
    299299
    300 What do you get if you combine a remote-controlled mobile thingy with a supercomputer capable of deep thought?  A paranoid android of course!  This example in the test directory handles both kinds of messages from the two examples above (the query and the turnLeft/turnRight commands) and proves that one polling thread is enough to handle multiple, completely different contexts, on a single bus.  So registering more than one method is low-cost compared to registering the first one.
     300What do you get if you combine a remote-controlled mobile thingy with a supercomputer capable of deep thought?  A paranoid android of course!  This example in the examples directory handles both kinds of messages from the two examples above (the query and the turnLeft/turnRight commands) and proves that one polling thread is enough to handle multiple, completely different contexts, on a single bus.  So registering more than one method is low-cost compared to registering the first one.
    301301
    302302=== Version History
Note: See TracChangeset for help on using the changeset viewer.