Dbus
The Navit dbus interface allows you to control certain aspects of Navit from outside the program. This document displays the requirements and implementation details of the Navit dbus interface.
Contents
Enabling[edit]
To be able to send and receive signals from Navit, you must enable it in navit.xml. Change line 13 to the following:
<plugin path="$NAVIT_LIBDIR/*/${NAVIT_LIBPREFIX}libbinding_dbus.so" active="yes"/>
Common actions[edit]
Zoom in/out[edit]
Zoom to level 500:
dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit org.navit_project.navit.navit.set_attr string:"zoom" variant:int32:500
Zoom in by factor of 2:
dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit org.navit_project.navit.navit.zoom int32:2
Zoom out by factor of 2:
dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit org.navit_project.navit.navit.zoom int32:-2
Set Position/Destination[edit]
Set position to longitude 24.0, latitude 65.0:
dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit org.navit_project.navit.navit.set_position string:"geo: 24.0 65.0"
Set destination to longitude 24.0, latitude 65.0:
dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit org.navit_project.navit.navit.set_destination string:"geo: 24.0 65.0" string:"comment"
Set map-view centre[edit]
Centre the map to longitude 24.0, latitude 65.0:
dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit org.navit_project.navit.navit.set_center_by_string string:"geo: 24.0 65.0"
Change map layout[edit]
Change layout to "Car-dark":
dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit org.navit_project.navit.navit.set_layout string:"Car-dark"
Change vehicle profile[edit]
Change profile to "bike":
dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit/default_vehicle org.navit_project.navit.vehicle.set_attr string:"profilename" variant:string:"bike"
[edit]
DBUS Service: "org.navit_project.navit"
DBUS Bus: Session bus
[edit]
DBUS Object Path: /org/navit_project/navit/navit/[]
The way navit use dbus is not really the usual way. If you want to control your navit instance (set_destination, zoom,…), you have first to do the following (examples are in python) :
1) get the navit general object
object = bus.get_object("org.navit_project.navit","/org/navit_project/navit")
2) get the interface of this object :
iface = dbus.Interface(object,dbus_interface="org.navit_project.navit")
3) get an iterator through navit instances :
iter=iface.attr_iter()
4) get the object path of the navit instance in your iterator :
path = object.get_attr_wi("navit",iter)
5) get the navit instance you are interested in :
navit=bus.get_object('org.navit_project.navit', path[1])
6) destroy the iter :
iface.attr_iter_destroy(iter)
The following methods have to be applied on the navit object.
Methods[edit]
Examples are shown for each command, and when using on the command line must be prefixed by:
dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit
When a coordinate is specified, the coordinate can be formatted like:
[Proj:]-0xX [-]0xX
where Proj can be mg or garmin. Default: mg. For example:
mg: 0x138a4a 0x5d773f
Or
[Proj:][D][D]Dmm.ss[S][S] N/S [D][D]DMM.ss[S][S]... E/W [Proj:][-][D]D.d[d]... [-][D][D]D.d[d]
where Proj must be geo. For example:
geo: 24.0 65.0
draw[edit]
Path: | .navit |
Arguments: | none |
Return: | none |
Description: | Forces a redraw of the current view of the map |
Example: |
|
add_message[edit]
Path: | .navit |
Arguments: | string: "message" |
Return: | none |
Description: | FIXME Adds a message to the messages label |
Example: |
|
set_center_by_string[edit]
Path: | .navit |
Arguments: | string: coordinates |
Return: | none |
Description: | Centres the map over the specified position. |
Example: |
|
set_center[edit]
Path: | .navit |
Arguments: | integer: projection string: coordinates
integer: projection integer: longitude integer: latitude |
Return: | none |
Description: | Centres the map over the specified position. |
Example: |
|
set_center_screen[edit]
Path: | .navit |
Arguments: | integer: pixel_x integer: pixel_y |
Return: | none |
Description: | Centers the map to a specific position on the screen. |
Example: |
|
set_layout[edit]
Path: | .navit |
Arguments: | string: layoutname |
Return: | none |
Description: | Changes the active map layout. |
Example: |
|
zoom[edit]
Path: | .navit |
Arguments: | integer: factor (integer: pixel_x integer: pixel_y) |
Return: | none |
Description: | Zooms into the map (positive factor) or out of the map (negative factor) by the factor specified. The factor must be integers greater than 1 (zoom in) or less than -1 (zoom out). Optionally, a screen position can be specified in pixel_x and pixel_y and the function will zoom into that particular position. In order to zoom to a specific zoom-level, use the set_attr method. |
Example: |
|
block[edit]
Path: | .navit |
Arguments: | integer: mode |
Return: | none |
Description: | FIXME |
Example: |
|
set_position[edit]
Path: | .navit |
Arguments: | string: coordinates integer: projection string: coordinates integer: projection integer: longitude integer: latitude |
Return: | none |
Description: | Sets the current position (useful if no gps position is available). |
Example: |
|
set_destination[edit]
Path: | .navit |
Arguments: | string: coordinates string:"comment" integer: projection string: coordinates string:"comment" integer: projection integer: longitude integer: latitude string:"comment" |
Return: | none |
Description: | Sets the destination for routing. |
Example: |
|
clear_destination[edit]
Path: | .navit |
Arguments: | none |
Return: | none |
Description: | Removes the destination and stops routing. |
Example: |
|
get_attr[edit]
Path: | .navit |
Arguments: | string:attribute |
Return: | string:attribute variant:value |
Description: | Gets the specified attribute value. The attribute can be anything from attr_def.h. |
Example: |
returns:
returns:
|
set_attr[edit]
Path: | .navit |
Arguments: | string:attribute variant:value |
Return: | none |
Description: | Sets the specified attribute value. The attribute can be anything from attr_def.h. As shown in the example below, this can be useful to zoom to a specific zoom level, insted of just zooming by a factor as with the zoom method. |
Example: |
|
export_as_gpx[edit]
Path: | .navit |
Arguments: | string:filename |
Return: | none |
Description: | Dump the current route, if any, into the file specified in the argument in the GPX format. |
Example: |
|
[edit]
Methods[edit]
Examples are shown for each command, and when using on the command line must be prefixed by:
dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit/default_vehicleprofile
get_attr[edit]
Path: | .vehicleprofile |
Arguments: | string:attribute |
Return: | string:attribute variant:value |
Description: | Gets the specified attribute value for the vehicleprofile. |
Example: |
returns:
returns:
|
set_attr[edit]
Path: | .vehicleprofile |
Arguments: | string:attribute variant:value |
Return: | none |
Description: | Sets the specified attribute value. The example below renames the current vehicleprofile. To actually change the vehicleprofile, use the set_attr method in the .vehicle path (see below). |
Example: |
|
[edit]
Methods[edit]
Examples are shown for each command, and when using on the command line must be prefixed by:
dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit/default_vehicle
set_attr[edit]
Path: | .vehicle |
Arguments: | string:attribute variant:value |
Return: | none |
Description: | Sets the specified attribute value. The example below changes the current vehicleprofile to "bike" . |
Example: |
|
[edit]
Methods[edit]
Examples are shown for each command, and when using on the command line must be prefixed by:
dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit/default_route
get_attr[edit]
Path: | .route |
Arguments: | string:attribute |
Return: | string:attribute variant:value |
Description: | Gets the specified attribute value. The attribute can be anything from route_get_attr() in navit/route.c |
Example: |
returns:
|
Signals[edit]
add bookmark signal[edit]
Setup the callback:
dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit org.navit_project.navit.callback_attr_new string:my_signal string:bookmark_map object path "/org/navit_project/navit/callback/0" dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit org.navit_project.navit.navit.add_attr string:callback variant:objpath:/org/navit_project/navit/callback/0
Replace "my_signal" with a signal name of your choice.
Now add a bookmark and you should see this in dbus-monitor --session:
signal sender=:1.927 -> dest=(null destination) path=/org/navit_project/navit; interface=org.navit_project.navit; member=my_signal
Undocumented methods[edit]
The following code comes from /binding/dbus/binding_dbus.c
{"", "attr_iter", "", "", "o", "attr_iter", request_config_attr_iter}, {"", "attr_iter_destroy", "o", "attr_iter", "", "", request_config_attr_iter_destroy}, {"", "get_attr", "s", "attrname", "sv", "attrname,value",request_config_get_attr}, {"", "get_attr_wi", "so", "attrname,attr_iter", "sv", "attrname,value",request_config_get_attr}, {"", "callback_new", "s", "signalname", "o", "callback",request_callback_new}, {"", "callback_attr_new", "ss", "signalname,attribute", "o", "callback",request_callback_new}, {"", "search_list_new", "o", "mapset", "o", "search",request_search_list_new}, {".callback","destroy", "", "", "", "", request_callback_destroy}, {".graphics","get_data", "s", "type", "ay", "data", request_graphics_get_data}, {".graphics","set_attr", "sv", "attribute,value", "", "", request_graphics_set_attr}, {".gui", "get_attr", "s", "attribute", "sv", "attrname,value", request_gui_get_attr}, {".gui", "command_parameter", "sa{sa{sv}}","command,parameter", "a{sa{sv}}", "return", request_gui_command}, {".gui", "command", "s", "command", "a{sa{sv}}", "return", request_gui_command}, {".navit", "resize", "ii", "upperleft,lowerright", "", "", request_navit_resize}, {".navit", "attr_iter", "", "", "o", "attr_iter", request_navit_attr_iter}, {".navit", "attr_iter_destroy", "o", "attr_iter", "", "", request_navit_attr_iter_destroy}, {".navit", "get_attr_wi", "so", "attribute,attr_iter", "sv", "attrname,value", request_navit_get_attr}, {".navit", "add_attr", "sv", "attribute,value", "", "", request_navit_add_attr}, {".navit", "remove_attr", "sv", "attribute,value", "", "", request_navit_remove_attr}, {".navit", "evaluate", "s", "command", "s", "", request_navit_evaluate}, {".map", "get_attr", "s", "attribute", "sv", "attrname,value", request_map_get_attr}, {".map", "set_attr", "sv", "attribute,value", "", "", request_map_set_attr}, {".mapset", "attr_iter", "", "", "o", "attr_iter", request_mapset_attr_iter}, {".mapset", "attr_iter_destroy", "o", "attr_iter", "", "", request_mapset_attr_iter_destroy}, {".mapset", "get_attr", "s", "attribute", "sv", "attrname,value", request_mapset_get_attr}, {".mapset", "get_attr_wi", "so", "attribute,attr_iter", "sv", "attrname,value", request_mapset_get_attr}, {".navigation","get_attr", "s", "attribute", "", "", request_navigation_get_attr}, {".route", "set_attr", "sv", "attribute,value", "", "", request_route_set_attr}, {".route", "add_attr", "sv", "attribute,value", "", "", request_route_add_attr}, {".route", "remove_attr", "sv", "attribute,value", "", "", request_route_remove_attr}, {".search_list","destroy", "", "", "", "", request_search_list_destroy}, {".search_list","get_result", "", "", "i(iii)a{sa{sv}}", "id,coord,dict", request_search_list_get_result}, {".search_list","search", "svi", "attribute,value,partial", "", "", request_search_list_search}, {".search_list","select", "sii", "attribute_type,id,mode", "", "", request_search_list_select}, {".tracking","get_attr", "s", "attribute", "", "", request_tracking_get_attr},