Skip to content

Commit 31441e7

Browse files
core/services/ardupilot_manager/mavlink_proxy: Implement TlogCondition to mavlink-server
1 parent c69e622 commit 31441e7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

core/services/ardupilot_manager/mavlink_proxy/MAVLinkServer.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import re
22
import subprocess
3-
from datetime import datetime
43
from typing import Optional
54

6-
from mavlink_proxy.AbstractRouter import AbstractRouter
5+
from mavlink_proxy.AbstractRouter import AbstractRouter, TLogCondition
76
from mavlink_proxy.Endpoint import Endpoint, EndpointType
87

98

@@ -38,9 +37,15 @@ def convert_endpoint(endpoint: Endpoint) -> str:
3837
return f"zenoh:{endpoint.place}:{endpoint.argument}"
3938
raise ValueError(f"Endpoint of type {endpoint.connection_type} not supported on MAVLink-Server.")
4039

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"
40+
def convert_tlog_condition(tlog_condition: TLogCondition) -> str:
41+
match tlog_condition:
42+
case TLogCondition.Always:
43+
return "?when=always"
44+
case TLogCondition.WhileArmed:
45+
return "?when=while_armed"
46+
47+
tlog_condition_arg = convert_tlog_condition(self.tlog_condition())
48+
logging_endpoint = f"tlogwriter://{self.logdir()}{tlog_condition_arg}"
4449
str_endpoints = [convert_endpoint(endpoint) for endpoint in [master_endpoint, *self.endpoints()]]
4550
endpoints = " ".join([*str_endpoints, logging_endpoint])
4651

0 commit comments

Comments
 (0)