mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-27 17:06:31 +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):
|
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.callback = callback
|
||||||
self.ivy_id = 0
|
self.ivy_id = 0
|
||||||
self.verbose = verbose
|
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:
|
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
|
|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
|
# first split on array delimiters
|
||||||
l = re.split('([|\"][^|]*[|\"])', larg[0])
|
l = re.split('([|\"][^|]*[|\"])', larg[0])
|
||||||
# strip spaces and filter out emtpy strings
|
# strip spaces and filter out emtpy strings
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ class PprzMessage(object):
|
|||||||
if f == name:
|
if f == name:
|
||||||
self._fieldvalues[idx] = value
|
self._fieldvalues[idx] = value
|
||||||
return
|
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):
|
def __str__(self):
|
||||||
ret = '%s.%s {' % (self.msg_class, self.name)
|
ret = '%s.%s {' % (self.msg_class, self.name)
|
||||||
|
|||||||
Reference in New Issue
Block a user