mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-18 16:18:03 +08:00
[python] fix PprzMessage and don't require msg callback in ivy_msg_interface.py
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user