summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meta-phosphor/classes/obmc-phosphor-dbus-service.bbclass2
-rw-r--r--meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.py25
-rw-r--r--meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/pyclient-sample.py60
-rw-r--r--meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/obmc-phosphor-example-pydbus.bb8
-rw-r--r--meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-sdbus/files/Makefile2
5 files changed, 93 insertions, 4 deletions
diff --git a/meta-phosphor/classes/obmc-phosphor-dbus-service.bbclass b/meta-phosphor/classes/obmc-phosphor-dbus-service.bbclass
index 4aacca496..1b175ea79 100644
--- a/meta-phosphor/classes/obmc-phosphor-dbus-service.bbclass
+++ b/meta-phosphor/classes/obmc-phosphor-dbus-service.bbclass
@@ -6,7 +6,7 @@ python() {
services = d.getVar('DBUS_SERVICES', True)
if services:
uris = " ".join( [ 'file://' + s + '.conf' for s in services.split() ] )
- d.appendVar('SRC_URI', uris)
+ d.appendVar('SRC_URI', ' ' + uris + ' ')
}
do_install_append() {
diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.py b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.py
index b0523b379..2b59b5887 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.py
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.py
@@ -42,10 +42,15 @@ class SampleObjectOne(dbus.service.Object):
class SampleObjectTwo(SampleObjectOne):
def __init__(self, bus, name):
super(SampleObjectTwo, self).__init__(bus, name)
- self.map = {}
+ self.map = { 'empty' : 'add values to me' }
+
+ @dbus.service.signal(IFACE_PREFIX + '.Dict', 'sss')
+ def DictMethodCalled(self, message, key, value):
+ pass
@dbus.service.method(IFACE_PREFIX + '.Dict', 'ss', '')
def SetAValueInTheDict(self, key, value):
+ self.DictMethodCalled("Dict method was invoked", key, value)
self.map[key] = value
@dbus.service.method(IFACE_PREFIX + '.Dict', 's', 's')
@@ -56,6 +61,24 @@ class SampleObjectTwo(SampleObjectOne):
def GetAllValuesFromTheDict(self):
return " ".join( [ x+ ':' + self.map[x] for x in self.map.keys() ] )
+ @dbus.service.method(dbus.PROPERTIES_IFACE, 'ss', 'v')
+ def Get(self, interface, prop):
+ return self.GetAll(interface)[prop]
+
+ @dbus.service.method(dbus.PROPERTIES_IFACE, 's', 'a{sv}')
+ def GetAll(self, interface):
+ if interface == IFACE_PREFIX + '.Dict':
+ return { 'Dict': self.map }
+
+ @dbus.service.method(dbus.PROPERTIES_IFACE, 'ssv')
+ def Set(self, interface, prop, value):
+ if prop == 'Dict':
+ self.map = value
+ self.PropertiesChanged(interface, { prop : value }, [])
+
+ @dbus.service.signal(dbus.PROPERTIES_IFACE, 'sa{sv}as')
+ def PropertiesChanged(self, interface, properties, invalidated_properties):
+ pass
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/pyclient-sample.py b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/pyclient-sample.py
new file mode 100644
index 000000000..e1010a542
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/pyclient-sample.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+
+# Contributors Listed Below - COPYRIGHT 2015
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+import gobject
+
+SERVICE_PREFIX = 'org.openbmc.examples'
+IFACE_PREFIX = 'org.openbmc.examples'
+BASE_OBJ_PATH = '/org/openbmc/examples/'
+
+def signal_callback(*a, **kw):
+ print "Got signal:"
+ print "intf: " + kw.get('intf', 'none')
+ print "path: " + kw.get('path', 'none')
+ print "member: " + kw.get('member', 'none')
+
+if __name__ == '__main__':
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+ bus = dbus.SystemBus()
+
+ obj0 = bus.get_object(SERVICE_PREFIX + '.PythonService0',
+ BASE_OBJ_PATH + 'path0/PythonObj')
+ obj1 = bus.get_object(SERVICE_PREFIX + '.PythonService1',
+ BASE_OBJ_PATH + 'path1/PythonObj')
+ echo0= dbus.Interface(obj0,
+ dbus_interface=IFACE_PREFIX + '.Echo')
+ echo1= dbus.Interface(obj0,
+ dbus_interface=IFACE_PREFIX + '.Echo')
+
+ print "Invoking Echo methods...."
+ print(echo0.Echo("hello"))
+ print(echo1.Echo("there"))
+
+ bus.add_signal_receiver(signal_callback, interface_keyword = 'intf',
+ path_keyword = 'path',
+ member_keyword = 'member')
+
+ print "Waiting for signals... (call a sample method to see something here)"
+ print "Press Ctrl^C to quit"
+ mainloop = gobject.MainLoop()
+
+ mainloop.run()
diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/obmc-phosphor-example-pydbus.bb b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/obmc-phosphor-example-pydbus.bb
index 7fee0b18e..c140c9be6 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/obmc-phosphor-example-pydbus.bb
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/obmc-phosphor-example-pydbus.bb
@@ -8,3 +8,11 @@ DBUS_SERVICES = " \
"
inherit obmc-phosphor-pydbus-service
+
+client = "pyclient-sample"
+SRC_URI += "file://${client}.py"
+
+do_install_append() {
+ install -d ${D}${bindir}
+ install -m 0755 ${WORKDIR}/${client}.py ${D}${bindir}/${client}
+}
diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-sdbus/files/Makefile b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-sdbus/files/Makefile
index 5166fdf59..0aaeb5341 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-sdbus/files/Makefile
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-sdbus/files/Makefile
@@ -6,8 +6,6 @@ INCLUDES += $(shell pkg-config --cflags $(DEPPKGS))
LIBS += $(shell pkg-config --libs $(DEPPKGS))
%.o : %.c
- echo $(CFLAGS)
- echo $(INCLUDES)
$(CC) -c $< $(CFLAGS) $(INCLUDES) -o $@
$(EXE): $(OBJS)
$(CC) $^ $(LDFLAGS) $(LIBS) -o $@