1
+ import configparser
1
2
import re
2
3
import subprocess
4
+ import tempfile
3
5
from typing import Optional
4
6
5
- from mavlink_proxy .AbstractRouter import AbstractRouter
7
+ from mavlink_proxy .AbstractRouter import AbstractRouter , TLogCondition
6
8
from mavlink_proxy .Endpoint import Endpoint , EndpointType
7
9
8
10
@@ -21,6 +23,22 @@ def _get_version(self) -> Optional[str]:
21
23
22
24
return None
23
25
26
+ def _write_configuration_file (self ) -> str :
27
+ def convert_tlog_condition (tlog_condition : TLogCondition ) -> str :
28
+ match tlog_condition :
29
+ case TLogCondition .Always :
30
+ return "always"
31
+ case TLogCondition .WhileArmed :
32
+ return "while-armed"
33
+ return ""
34
+
35
+ config = configparser .ConfigParser ()
36
+ config ["General" ] = {"LogMode" : convert_tlog_condition (self .tlog_condition ())}
37
+
38
+ with tempfile .NamedTemporaryFile ("w" , suffix = ".conf" , delete = False ) as temp_file :
39
+ config .write (temp_file , space_around_delimiters = True )
40
+ return temp_file .name
41
+
24
42
def assemble_command (self , master_endpoint : Endpoint ) -> str :
25
43
# Convert endpoint format to mavlink-router format
26
44
def convert_endpoint (endpoint : Endpoint ) -> str :
@@ -63,7 +81,7 @@ def convert_endpoint(endpoint: Endpoint) -> str:
63
81
f"Master endpoint of type { master_endpoint .connection_type } not supported on MavlinkRouter."
64
82
)
65
83
66
- return f"{ self .binary ()} { convert_endpoint (master_endpoint )} { endpoints } -l { self .logdir ()} -T { self .logdir ()} "
84
+ return f"{ self .binary ()} { convert_endpoint (master_endpoint )} { endpoints } -l { self .logdir ()} -T { self .logdir ()} -c { self . _write_configuration_file () } "
67
85
68
86
@staticmethod
69
87
def name () -> str :
0 commit comments