Merge "Make diagnostic_injector print more informative status"
diff --git a/tools/emulator/diagnostic_builder.py b/tools/emulator/diagnostic_builder.py
index 9365ab2..b205a5b 100644
--- a/tools/emulator/diagnostic_builder.py
+++ b/tools/emulator/diagnostic_builder.py
@@ -81,3 +81,9 @@
     def build(self):
         self.bytes_value = str(self.bitmask)
         return self
+
+    def __str__(self):
+        s = "diagnostic event {\n"
+        for x in ['string_value', 'int32_values', 'float_values']:
+            s = s + "\t%s: %s\n" % (x, self.__dict__[x])
+        return s  + "}"
diff --git a/tools/emulator/diagnostic_injector.py b/tools/emulator/diagnostic_injector.py
index 1fee300..d2a784d 100755
--- a/tools/emulator/diagnostic_injector.py
+++ b/tools/emulator/diagnostic_injector.py
@@ -88,9 +88,9 @@
                 # also, timestamps are in nanoseconds, but sleep() uses seconds
                 time.sleep((currentTimestamp-lastTimestamp)/1000000000)
             lastTimestamp = currentTimestamp
-            print ("Sending event at %d" % currentTimestamp),
             # now build the event
-            eventTypeData = self.eventTypeData[event['type']]
+            eventType = event['type'].encode('utf-8')
+            eventTypeData = self.eventTypeData[eventType]
             builder = eventTypeData['builder']()
             builder.setStringValue(event.get('stringValue', ''))
             for intValue in event['intValues']:
@@ -98,12 +98,17 @@
             for floatValue in event['floatValues']:
                 floatSensorsMapping[floatValue['id']](builder, floatValue['value'])
             builtEvent = builder.build()
-            # and send it
-            print(self.chat(
+            print ("Sending %s %s..." % (eventType, builtEvent)),
+        # and send it
+            status = self.chat(
                 lambda hal:
                     hal.setProperty(eventTypeData['property'],
                         0,
-                        builtEvent)))
+                        builtEvent)).status
+            if status == 0:
+                print("ok!")
+            else:
+                print("fail: %s" % status)
 
 if len(sys.argv) < 2:
     print("Syntax: diagnostic_injector.py <path/to/diagnostic.json>")