![]() |
![]() |
![]() |
Gypsy Reference Manual | ![]() |
---|
The Gypsy daemon sits on the system bus, and we'll be using the GLib main loop for signals. This requires a little setup.
#! /usr/bin/python import dbus, dbus.mainloop.glib # Hook into the glib main loop dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) # Connect to the system bus bus = dbus.SystemBus()
Now that we're connected to the bus, we can get an object for the Gypsy daemon.
# Get a connection to the Gypsy daemon daemon = bus.get_object("org.freedesktop.Gypsy", "/org/freedesktop/Gypsy") # Get an object conforming to the Server interface control = dbus.Interface(daemon, "org.freedesktop.Gypsy.Server")
The control
object now implements the
Server interface, which has a single method:
Create
. This is used to create new
Device objects.
# This gives us an object path to the new device path = control.Create("00:11:22:33:44:55") # Now get the object at that path gps = bus.get_object("org.freedesktop.Gypsy", path)
The object gps
now represents the GPS, and implements
several other interfaces which will be covered next.