forked from alanbjohnston/CubeSatSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig
executable file
·319 lines (255 loc) · 6.47 KB
/
config
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#!/bin/bash
echo "CubeSatSim v1.2 configuration tool"
if [ "$2" = "-n" ]; then
norestart=1
else
norestart=0
fi
if [ "$1" = "" ]; then
value=`cat /home/pi/CubeSatSim/.mode`
echo "$value" > /dev/null
set -- $value
if [ "$1" = "a" ]; then
echo "APRS mode is set"
elif [ "$1" = "m" ]; then
echo "CW mode is set"
elif [ "$1" = "f" ]; then
echo "FSK mode is set"
elif [ "$1" = "b" ]; then
echo "BPSK mode is set"
elif [ "$1" = "s" ]; then
echo "SSTV mode is set"
else
echo
fi
value=`cat /home/pi/CubeSatSim/sim.cfg`
echo "$value" > /dev/null
set -- $value
if [ "$5" = "y" ] || [ "$5" = "yes" ] ; then
# sim="yes"
echo "Simulated Telemetry is ON"
else
# sim="no"
echo "Simulated Telemetry is OFF"
fi
echo
echo -e "Current sim.cfg configuration file:"
# echo
echo $1 $2 $3 $4 $5
echo
# echo
# echo "To change, include an OPTION"
# echo
set -- "-h"
fi
if [ "$1" = "-i" ]; then
echo "Restarting CubeSatSim"
sudo systemctl restart cubesatsim
exit
elif [ "$1" = "-a" ]; then
echo "changing CubeSatSim to AFSK mode"
sudo echo "a" > /home/pi/CubeSatSim/.mode
sudo systemctl restart cubesatsim
exit
elif [ "$1" = "-m" ]; then
echo "changing CubeSatSim to CW mode"
sudo echo "m" > /home/pi/CubeSatSim/.mode
sudo systemctl restart cubesatsim
exit
elif [ "$1" = "-f" ]; then
echo "changing CubeSatSim to FSK mode"
sudo echo "f" > /home/pi/CubeSatSim/.mode
sudo systemctl restart cubesatsim
exit
elif [ "$1" = "-b" ]; then
echo "changing CubeSatSim to BPSK mode"
sudo echo "b" > /home/pi/CubeSatSim/.mode
sudo systemctl restart cubesatsim
exit
elif [ "$1" = "-s" ]; then
echo "changing CubeSatSim to SSTV mode"
sudo echo "s" > /home/pi/CubeSatSim/.mode
sudo systemctl restart cubesatsim
exit
elif [ "$1" = "-h" ]; then
echo "config OPTION"
echo
echo "Changes CubeSatSim mode, resets, or modifies configuration file"
echo
echo " -h This help info"
echo " -a Change to AFSK/APRS mode"
echo " -m Change to CW mode"
echo " -f Change to FSK/DUV mode"
echo " -b Change to BPSK mode"
echo " -s Change to SSTV mode"
echo " -i Restarts CubeSatsim software"
echo " -c Change the CALLSIGN in the configuration file sim.cfg"
echo " -t Change the Simulated Telemetry setting in sim.cfg"
echo " -r Change the Resets Count in the configuration file sim.cfg"
echo " -l Change the Latitude and Longitude in the configuration file sim.cfg"
echo
exit
elif [ "$1" = "-t" ]; then
echo
echo "Editing the Simulated Telemetry setting in"
echo "the configuration file for CubeSatSim"
echo
value=`cat /home/pi/CubeSatSim/sim.cfg`
echo "$value" > /dev/null
set -- $value
if [ "$5" = "yes" ] || [ "$5" = "y" ]; then
echo "Simualted Telemetry is ON"
else
echo "Simualted Telemetry is OFF"
fi
echo
# echo $1 $2 $3 $4
echo "Do you want Simulated Telemetry ON (y/n) "
read sim
echo
if [ "$sim" = "y" ] || [ "$sim" = "yes" ] ; then
sim="yes"
echo "Simulated Telemetry is ON"
else
sim="no"
echo "Simulated Telemetry is OFF"
fi
echo
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
echo
echo $1 $2 $3 $4 $sim
echo $1 $2 $3 $4 $sim > /home/pi/CubeSatSim/sim.cfg
echo
echo "Restarting CubeSatSim with new configuraation file"
echo
sudo systemctl restart cubesatsim
elif [ "$1" = "-c" ]; then
echo
echo "Editing the CALLSIGN in the"
echo "configuration file for CubeSatSim"
echo
echo "Return keeps current value."
# echo -e "Current sim.cfg configuration file:"
# echo
value=`cat /home/pi/CubeSatSim/sim.cfg`
echo "$value" > /dev/null
set -- $value
echo "Current value of CALLSIGN is"
echo $1
echo
# echo $1 $2 $3 $4 $5
echo "Enter callsign in all capitals: "
read callsign
if [ -z $callsign ] ; then
callsign="$1"
echo "Keeping value of" $callsign
norestart=1
else
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
echo $callsign $2 $3 $4 $5
echo $callsign $2 $3 $4 $5 > /home/pi/CubeSatSim/sim.cfg
fi
if [ "$norestart" = "1" ]; then
echo
else
echo
echo "Restarting CubeSatSim with new configuraation file"
echo
sudo systemctl restart cubesatsim
fi
elif [ "$1" = "-r" ]; then
echo
echo "Editing the Reset Count in the"
echo "configuration file for CubeSatSim"
echo
echo "Return keeps current value."
# echo -e "Current sim.cfg configuration file:"
# echo
value=`cat /home/pi/CubeSatSim/sim.cfg`
echo "$value" > /dev/null
set -- $value
echo
echo "Current value of Reset Count is"
echo $2
echo
# echo $1 $2 $3 $4 $5
echo -e "Enter Reset Count (integer): "
read resets
if [ -z $resets ] ; then
resets="$2"
echo "Keeping value of" $resets
fi
if ! [[ $resets =~ ^[0-9]+$ ]] ; then
echo "Error: not an integer!"
resets="$2"
echo "Keeping value of" $resets
norestart=1
else
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
echo $1 $resets $3 $4 $5
echo $1 $resets $3 $4 $5 > /home/pi/CubeSatSim/sim.cfg
fi
if [ "$norestart" = "1" ]; then
echo
else
echo
echo "Restarting CubeSatSim with new configuraation file"
echo
sudo systemctl restart cubesatsim
fi
elif [ "$1" = "-l" ]; then
echo
echo "Editing latitude and longitude in the"
echo "configuration file for CubeSatSim"
echo "(Only used for APRS telemetry)"
echo
echo "Return keeps current value."
# echo -e "Current sim.cfg configuration file:"
# echo
value=`cat /home/pi/CubeSatSim/sim.cfg`
echo "$value" > /dev/null
set -- $value
echo
echo "Current value of latitude is"
echo $3
echo
# echo $1 $2 $3 $4 $5
echo -e "Enter latitude (decimal degrees, positive is north): "
read lat
if [ -z $lat ] ; then
lat="$3"
echo "Keeping value of" $lat
fi
if ! [[ $lat =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]] ; then
echo "Error: not a number!"
lat="$3"
echo "Keeping value of" $lat
fi
echo
echo "Current value of longitude is"
echo $4
echo
echo -e "Enter longitude (decimal degrees, positive is east): "
read long
if [ -z $long ] ; then
long="$4"
echo "Keeping value of" $long
fi
if ! [[ $long =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]] ; then
echo "Error: not a number!"
long="$4"
echo "Keeping value of" $long
fi
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
echo $1 $2 $lat $long $5
echo $1 $2 $lat $long $5 > /home/pi/CubeSatSim/sim.cfg
if [ "$norestart" = "1" ]; then
echo
else
echo
echo "Restarting CubeSatSim with new configuraation file"
echo
sudo systemctl restart cubesatsim
fi
fi
# sudo systemctl restart cubesatsim