-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter_gpio.py
249 lines (220 loc) · 8.68 KB
/
filter_gpio.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
from gpiozero import LEDBoard
import os
import subprocess
from subprocess import check_call, CalledProcessError
import pyautogui
import time
def clear_console():
os.system('cls' if os.name == 'nt' else 'clear')
#1)GPIO12 purple
#2)GPIO27 blu
#3)GPIO22 green
#4)GPIO23 yellow
#5)GPIO24 orange
#6)GPIO25 red
#7)GPIO26 brown
#8)GPIO13 gray - transistor
gpio_1M6_2M5 = 12
gpio_2M5_4M7 = 27
gpio_4M7_7M5 = 22
gpio_7M5_14M5 = 23
gpio_14M5_21M5 = 24
gpio_21M5_33M = 25
gpio_33M_56M = 26
gpio_transistor = 13
filter_outputs = LEDBoard(gpio_1M6_2M5, gpio_2M5_4M7, gpio_4M7_7M5, gpio_7M5_14M5, gpio_14M5_21M5, gpio_21M5_33M, gpio_33M_56M, gpio_transistor)
status_1M6_2M5 = 0
status_2M5_4M7 = 0
status_4M7_7M5 = 0
status_7M5_14M5 = 0
status_14M5_21M5 = 0
status_21M5_33M = 0
status_33M_56M = 0
transistor_status = 0
filter_outputs.off()
launched_process = 0
while True:
# Call the function to clear the console
clear_console()
if transistor_status == 0:
transistor_status_str = "RF2"
else:
transistor_status_str = "RF1"
# ask the user which filter ouput to turn on
print("Current status:")
print("+---------+---------+---------+----------+-----------+----------+---------+------------+")
print("| 1M6 2M5 | 2M5 4M7 | 4M7 7M5 | 7M5 14M5 | 14M5 21M5 | 21M5 33M | 33M 56M | RF switch |")
print("| 160 m | 80 m | 40 m | 30m 20m | 14m 17 15m| 10 m | 6 m | |")
print("+---------+---------+---------+----------+-----------+----------+---------+------------+")
print(f"| {status_1M6_2M5} | {status_2M5_4M7} | {status_4M7_7M5} | {status_7M5_14M5} | {status_14M5_21M5} | {status_21M5_33M} | {status_33M_56M} | {transistor_status_str} |")
print("+---------+---------+---------+----------+-----------+----------+---------+------------+")
print("| | | | | | | | 8 = RF1 |")
print("| 1 | 2 | 3 | 4 | 5 | 6 | 7 | Loop ant |")
print("| | | | | | | | 9 = RF2 |")
print("+---------+---------+---------+----------+-----------+----------+---------+ Wire ant |")
print("+ 10 = ALL OFF | |")
print("+--------------------------------------------------------------------------------------+")
print("USB manager:")
print("11 - Switch ON USB")
print("12 - Switch OFF USB")
print("13 - Read USB status")
print("RTL-SDR server:")
print("14 - Run RTL-SDR TCP (bias tee OFF)")
print("Airspy server:")
print("15 - Run Airspy server Airspy (bias tee ON!!!)")
print("16 - Run Airspy server RTL-SDR (bias tee ON!!!)")
print("17 - Run Airspy server Airspy (bias tee off)")
print("Select one of the numbers - 20 to exit:")
# print("1) 1.6 - 2.5 MHz")
# print("2) 2.5 - 4.7 MHz")
# print("3) 4.7 - 7.5 MHz")
# print("4) 7.5 - 14.5 MHz")
# print("5) 14.5 - 21.5 MHz")
# print("6) 21.5 - 33 MHz")
# print("7) 33 - 56 MHz")
# print("---")
# print("8) Transistor ON")
# print("9) Transistor OFF")
# print("---")
# print("0) Exit")
user_input = input(">")
if user_input == "":
selected_option = 0
else:
selected_option = int(user_input)
if selected_option == 1:
status_1M6_2M5 = 1
status_2M5_4M7 = 0
status_4M7_7M5 = 0
status_7M5_14M5 = 0
status_14M5_21M5 = 0
status_21M5_33M = 0
status_33M_56M = 0
elif selected_option == 2:
status_1M6_2M5 = 0
status_2M5_4M7 = 1
status_4M7_7M5 = 0
status_7M5_14M5 = 0
status_14M5_21M5 = 0
status_21M5_33M = 0
status_33M_56M = 0
elif selected_option == 3:
status_1M6_2M5 = 0
status_2M5_4M7 = 0
status_4M7_7M5 = 1
status_7M5_14M5 = 0
status_14M5_21M5 = 0
status_21M5_33M = 0
status_33M_56M = 0
elif selected_option == 4:
status_1M6_2M5 = 0
status_2M5_4M7 = 0
status_4M7_7M5 = 0
status_7M5_14M5 = 1
status_14M5_21M5 = 0
status_21M5_33M = 0
status_33M_56M = 0
elif selected_option == 5:
status_1M6_2M5 = 0
status_2M5_4M7 = 0
status_4M7_7M5 = 0
status_7M5_14M5 = 0
status_14M5_21M5 = 1
status_21M5_33M = 0
status_33M_56M = 0
elif selected_option == 6:
status_1M6_2M5 = 0
status_2M5_4M7 = 0
status_4M7_7M5 = 0
status_7M5_14M5 = 0
status_14M5_21M5 = 0
status_21M5_33M = 1
status_33M_56M = 0
elif selected_option == 7:
status_1M6_2M5 = 0
status_2M5_4M7 = 0
status_4M7_7M5 = 0
status_7M5_14M5 = 0
status_14M5_21M5 = 0
status_21M5_33M = 0
status_33M_56M = 1
elif selected_option == 8:
transistor_status = 1
elif selected_option == 9:
transistor_status = 0
elif selected_option == 10:
status_1M6_2M5 = 0
status_2M5_4M7 = 0
status_4M7_7M5 = 0
status_7M5_14M5 = 0
status_14M5_21M5 = 0
status_21M5_33M = 0
status_33M_56M = 0
#transistor_status = 0
filter_outputs.value = (status_1M6_2M5, status_2M5_4M7, status_4M7_7M5, status_7M5_14M5, status_14M5_21M5, status_21M5_33M, status_33M_56M, transistor_status)
if selected_option == 11:
print("Activating USB...")
try:
check_call(['sudo', 'uhubctl', '-l', '1-1', '-a', '1'])
except CalledProcessError as e:
# Handle the exception
print(f"Command failed with return code {e.returncode}")
print(f"Command output: {e.output}")
input("Press Enter to continue...")
if selected_option == 12:
print("De-activating USB...")
try:
check_call(['sudo', 'uhubctl', '-l', '1-1', '-a', '0'])
except CalledProcessError as e:
# Handle the exception
print(f"Command failed with return code {e.returncode}")
print(f"Command output: {e.output}")
input("Press Enter to continue (via Vnc)...")
if selected_option == 13:
print("Checking USB...")
try:
check_call(['sudo', 'uhubctl'])
except CalledProcessError as e:
# Handle the exception
print(f"Command failed with return code {e.returncode}")
print(f"Command output: {e.output}")
input("Press Enter to continue...")
if selected_option == 14:
print("Launching rtl-tcp...")
#subprocess.Popen(["rtl-tcp", "-a", "192.168.2.82"], shell=True, stdin=None, stdout=None, stderr=None)
#subprocess.Popen(["xterm", "-hold", "-e", "rtl_tcp -a 192.168.2.82"], stdin=None, stdout=None, stderr=None)
process = subprocess.Popen(["xterm", "-hold", "-e", "rtl_tcp -a 192.168.2.82"], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, preexec_fn=os.setsid)
#os.system("xterm -hold -e 'rtl_tcp -a 192.168.2.82'")
launched_process = 1
time.sleep(3)
pyautogui.hotkey('alt','tab')
print("Done")
if selected_option == 15:
print("Launching spyserver Airspy Biastee ON...")
process = subprocess.Popen(["xterm", "-hold", "-e", "spyserver ~/spyserver/spyserver_dav_airspy.config"], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, preexec_fn=os.setsid)
launched_process = 1
time.sleep(3)
pyautogui.hotkey('alt','tab')
print("Done")
if selected_option == 16:
print("Launching spyserver RTLSDR...")
process = subprocess.Popen(["xterm", "-hold", "-e", "spyserver ~/spyserver/spyserver_dav_rtl.config"], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, preexec_fn=os.setsid)
launched_process = 1
time.sleep(3)
pyautogui.hotkey('alt','tab')
print("Done")
if selected_option == 17:
print("Launching spyserver Airspy Biastee off...")
process = subprocess.Popen(["xterm", "-hold", "-e", "spyserver ~/spyserver/spyserver_dav_airspy_biasoff.config"], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, preexec_fn=os.setsid)
launched_process = 1
time.sleep(3)
pyautogui.hotkey('alt','tab')
print("Done")
if selected_option == 20:
print("Exiting... Are you sure? Y/n")
answer = input()
if answer == "Y" or answer == "y" or answer == "":
if launched_process == 1:
process.kill()
break
print("Bye!")