Skip to content

Commit 12f2f06

Browse files
authored
Fixes (#88)
Add --nboosters and --nsustainer and also fix mkdir issues
1 parent d5ccbc0 commit 12f2f06

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

ground/gss_combiner/main.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,41 @@ def parse_params(arguments):
9090
if args.relay is not None:
9191
relay_sources = args.relay.split(",")
9292

93+
comports = list_ports.comports()
94+
port_idx = 0
9395
if args.nboosters is not None:
9496
for i in range(0, args.nboosters):
95-
booster_sources.append(str(list_ports.comports()[i]).split(' ')[0])
97+
while port_idx < len(list_ports.comports()) and list_ports.comports()[port_idx].vid != 0x239A:
98+
port_idx += 1
99+
if port_idx >= len(list_ports.comports()):
100+
# Warn
101+
print("\x1b[33mWARNING: Not enough COM ports available for boosters! Stopping at ", port_idx, "\x1b[0m")
102+
break
103+
booster_sources.append(str(list_ports.comports()[port_idx].device))
104+
port_idx += 1
96105

97106
if args.nsustainers is not None:
98-
for i in range(args.nboosters, args.nsustainers + args.nboosters):
99-
sustainer_sources.append(str(list_ports.comports()[i]).split(' ')[0])
107+
for i in range(0, args.nsustainers):
108+
while port_idx < len(list_ports.comports()) and list_ports.comports()[port_idx].vid != 0x239A:
109+
port_idx += 1
110+
if port_idx >= len(list_ports.comports()):
111+
# Warn
112+
print("\x1b[33mWARNING: Not enough COM ports available for sustainers! Stopping at ", port_idx, "\x1b[0m")
113+
break
114+
sustainer_sources.append(str(list_ports.comports()[port_idx].device))
115+
port_idx += 1
100116

101117
if args.nrelays is not None:
102-
for i in range(args.nsustainers + args.nboosters, args.nrelays + args.nsustainers + args.nboosters):
103-
relay_sources.append(str(list_ports.comports()[i]).split(' ')[0])
118+
for i in range(0, args.nrelays):
119+
# Check if vid == 0x239A
120+
while port_idx < len(list_ports.comports()) and list_ports.comports()[port_idx].vid != 0x239A:
121+
port_idx += 1
122+
if port_idx >= len(list_ports.comports()):
123+
# Warn
124+
print("\x1b[33mWARNING: Not enough COM ports available for relays! Stopping at ", port_idx, "\x1b[0m")
125+
break
126+
relay_sources.append(str(list_ports.comports()[port_idx].device))
127+
port_idx += 1
104128

105129
is_local = args.local
106130
should_log = not args.no_log

ground/gss_combiner/util/logger.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from enum import Enum
55
import datetime
66
from pathlib import Path
7+
import os
78

89
class LoggerOptions():
910
def __init__(self, should_log, is_verbose) -> None:
@@ -21,7 +22,9 @@ class LoggerStream():
2122
def __init__(self, options: LoggerOptions, type: LoggerType, name: str, meta_category: str) -> None:
2223
self.__title = type.value + " " + name
2324
self.__filename = "./outputs/" + str(int(datetime.datetime.now().timestamp())) + "_" + type.value + "_" + name + "_raw_output.txt"
24-
Path("./outputs/").mkdir(parents=True, exist_ok=True)
25+
# Get dirname of filename
26+
27+
Path(os.path.dirname(self.__filename)).mkdir(parents=True, exist_ok=True)
2528
self.__lstype = type
2629
self.__meta_cat = meta_category
2730

0 commit comments

Comments
 (0)