Skip to content

Commit d303845

Browse files
core/services/ardupilot_manager/mavlink_proxy: Implement TlogCondition to mavlink-server
1 parent 7dcbd5e commit d303845

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

core/services/ardupilot_manager/mavlink_proxy/MAVLinkServer.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from datetime import datetime
44
from typing import Optional
55

6-
from mavlink_proxy.AbstractRouter import AbstractRouter
6+
from mavlink_proxy.AbstractRouter import AbstractRouter, TLogCondition
77
from mavlink_proxy.Endpoint import Endpoint, EndpointType
88

99

@@ -38,9 +38,16 @@ def convert_endpoint(endpoint: Endpoint) -> str:
3838
return f"zenoh:{endpoint.place}:{endpoint.argument}"
3939
raise ValueError(f"Endpoint of type {endpoint.connection_type} not supported on MAVLink-Server.")
4040

41-
# MAVlink-Server takes direct file paths as endpoints, so we generate a timestamped file path
42-
now = datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
43-
logging_endpoint = f"tlogwriter:/root/.config/ardupilot-manager/firmware/logs/mavlink-server-{now}.tlog"
41+
def convert_tlog_condition(tlog_condition: TLogCondition) -> str:
42+
match tlog_condition:
43+
case TLogCondition.Always:
44+
return "?when=always"
45+
case TLogCondition.WhileArmed:
46+
return "?when=while_armed"
47+
return ""
48+
49+
tlog_condition_arg = convert_tlog_condition(self.tlog_condition())
50+
logging_endpoint = f"tlogwriter://{self.logdir()}{tlog_condition_arg}"
4451
str_endpoints = [convert_endpoint(endpoint) for endpoint in [master_endpoint, *self.endpoints()]]
4552
endpoints = " ".join([*str_endpoints, logging_endpoint])
4653

0 commit comments

Comments
 (0)