mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-30 11:37:06 +08:00
[python] ivy_msg_interface: find message class by name
and don't treat sender_name (first string in ivy message) as msg_class
This commit is contained in:
@@ -72,28 +72,21 @@ class IvyMessagesInterface(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# check which message class it is
|
# check which message class it is
|
||||||
# pass non-telemetry messages with ac_id 0
|
msg_name = data[1]
|
||||||
if data[0] in ["sim", "ground_dl", "dl"]:
|
msg_class, msg_name = messages_xml_map.find_msg_by_name(msg_name)
|
||||||
if self.verbose:
|
if msg_class is None:
|
||||||
print("ignoring message " + larg[0])
|
print("Ignoring unknown message " + larg[0])
|
||||||
sys.stdout.flush()
|
|
||||||
return
|
return
|
||||||
elif data[0] in ["ground"]:
|
# pass non-telemetry messages with ac_id 0
|
||||||
msg_class = data[0]
|
if msg_class == "telemetry":
|
||||||
msg_name = data[1]
|
|
||||||
ac_id = 0
|
|
||||||
values = list(filter(None, data[2:]))
|
|
||||||
else:
|
|
||||||
try:
|
try:
|
||||||
ac_id = int(data[0])
|
ac_id = int(data[0])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
if self.verbose:
|
print("ignoring message " + larg[0])
|
||||||
print("ignoring message " + larg[0])
|
sys.stdout.flush()
|
||||||
sys.stdout.flush()
|
else:
|
||||||
return
|
ac_id = 0
|
||||||
msg_class = "telemetry"
|
values = list(filter(None, data[2:]))
|
||||||
msg_name = data[1]
|
|
||||||
values = list(filter(None, data[2:]))
|
|
||||||
msg = PprzMessage(msg_class, msg_name)
|
msg = PprzMessage(msg_class, msg_name)
|
||||||
msg.set_values(values)
|
msg.set_values(values)
|
||||||
self.callback(ac_id, msg)
|
self.callback(ac_id, msg)
|
||||||
|
|||||||
@@ -72,6 +72,17 @@ def parse_messages(messages_file=''):
|
|||||||
message_dictionary_coefs[class_name][message_id].append(1.)
|
message_dictionary_coefs[class_name][message_id].append(1.)
|
||||||
|
|
||||||
|
|
||||||
|
def find_msg_by_name(name):
|
||||||
|
if not message_dictionary:
|
||||||
|
parse_messages()
|
||||||
|
for msg_class in message_dictionary:
|
||||||
|
if name in message_dictionary[msg_class]:
|
||||||
|
#print("found msg name %s in class %s" % (name, msg_class))
|
||||||
|
return msg_class, name
|
||||||
|
print("Error: msg_name %s not found." % name)
|
||||||
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
def get_msgs(msg_class):
|
def get_msgs(msg_class):
|
||||||
if not message_dictionary:
|
if not message_dictionary:
|
||||||
parse_messages()
|
parse_messages()
|
||||||
|
|||||||
Reference in New Issue
Block a user