[python] fix PprzMessage and don't require msg callback in ivy_msg_interface.py

This commit is contained in:
Felix Ruess
2015-09-14 04:30:43 +02:00
parent cbdbac5174
commit 858427bb11
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -16,7 +16,7 @@ from pprz_msg.message import PprzMessage
class IvyMessagesInterface(object):
def __init__(self, callback, init=True, verbose=False, bind_regex='(.*)'):
def __init__(self, callback=None, init=True, verbose=False, bind_regex='(.*)'):
self.callback = callback
self.ivy_id = 0
self.verbose = verbose
@@ -47,6 +47,10 @@ class IvyMessagesInterface(object):
Basically parts/args in string are separated by space, but char array can also contain a space:
|f,o,o, ,b,a,r| in old format or "foo bar" in new format
"""
# return if no callback is set
if self.callback is None:
return
# first split on array delimiters
l = re.split('([|\"][^|]*[|\"])', larg[0])
# strip spaces and filter out emtpy strings
+1 -1
View File
@@ -130,7 +130,7 @@ class PprzMessage(object):
if f == name:
self._fieldvalues[idx] = value
return
raise AttributeError("Msg %s has no field of name %s" % (self.name, key))
raise AttributeError("Msg %s has no field of name %s" % (self.name, name))
def __str__(self):
ret = '%s.%s {' % (self.msg_class, self.name)