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,21 @@ 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
+
34
+ config = configparser .ConfigParser ()
35
+ config ["General" ] = {"LogMode" : convert_tlog_condition (self .tlog_condition ())}
36
+
37
+ with tempfile .NamedTemporaryFile ("w" , suffix = ".conf" , delete = False ) as temp_file :
38
+ config .write (temp_file , space_around_delimiters = True )
39
+ return temp_file .name
40
+
24
41
def assemble_command (self , master_endpoint : Endpoint ) -> str :
25
42
# Convert endpoint format to mavlink-router format
26
43
def convert_endpoint (endpoint : Endpoint ) -> str :
@@ -63,7 +80,7 @@ def convert_endpoint(endpoint: Endpoint) -> str:
63
80
f"Master endpoint of type { master_endpoint .connection_type } not supported on MavlinkRouter."
64
81
)
65
82
66
- return f"{ self .binary ()} { convert_endpoint (master_endpoint )} { endpoints } -l { self .logdir ()} -T { self .logdir ()} "
83
+ return f"{ self .binary ()} { convert_endpoint (master_endpoint )} { endpoints } -l { self .logdir ()} -T { self .logdir ()} -c { self . _write_configuration_file () } "
67
84
68
85
@staticmethod
69
86
def name () -> str :
0 commit comments