-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathira
More file actions
executable file
·571 lines (507 loc) · 9.5 KB
/
ira
File metadata and controls
executable file
·571 lines (507 loc) · 9.5 KB
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
#!/bin/bash
#
#
# Startup script for IRA Integrated Radio Astronomy system
#
#
function errordialog {
if [ $MENU = "True" ]
then
zenity --title "IRA Error" --error --text="$1"
else
echo $1
fi
}
#
# Setup PYTHONPATH
#
function pythonpath {
PYTHONPATH=unset
for mach in 64 ""
do
for lib in /usr/lib /usr/local/lib /opt/lib
do
for vers in 2.8 2.7 2.6 2.5
do
for pkg in site-packages dist-packages
do
td=${lib}${mach}/python${vers}/${pkg}
if [ -d $td/gnuradio ]
then
PYTHONPATH=$td
break
fi
done
if [ $PYTHONPATH != unset ]
then
break
fi
done
if [ $PYTHONPATH != unset ]
then
break
fi
done
if [ $PYTHONPATH != unset ]
then
break
fi
done
}
function help_prefix {
RCVR_HELP_PREFIX=/usr/local
if [ -d /usr/local/share/doc/ira ]
then
RCVR_HELP_PREFIX=/usr/local
elif [ -d /usr/share/doc/ira ]
then
RCVR_HELP_PREFIX=/usr
fi
}
#
# Probe for possible USRP2 or USRP1
#
function probe {
#
# Give priority to USRP2/N2XX
#
RCVR_HW_TYPE=none
RCVR_HW_ADDR=none
RCVR_HW_CLOCK=64e6
for usrp2_addr in 192.168.10.2 192.168.20.2 192.168.30.2 192.168.40.2
do
uhd_usrp_probe --args addr=$usrp2_addr >tmp$$ 2>&1
if grep -q mac-addr tmp$$
then
RCVR_HW_TYPE=USRP2
RCVR_HW_ADDR="addr="$usrp2_addr
RCVR_HW_CLOCK=100e6
break
fi
done
#
# If we haven't already found a USRP2, try for a USRP1
#
if [ $RCVR_HW_TYPE = none ]
then
uhd_usrp_probe --args "type=usrp1" >tmp$$ 2>&1
if grep -qi mboard tmp$$
then
RCVR_HW_TYPE=USRP1
RCVR_HW_ADDR="type=usrp1"
RCVR_HW_CLOCK=64e6
fi
fi
if [ $RCVR_HW_TYPE = none ]
then
uhd_usrp_probe --args "type=b100" >tmp$$ 2>&1
if grep -qi mboard tmp$$
then
RCVR_HW_TYPE=B100
RCVR_HW_ADDR="type=b100"
RCVR_HW_CLOCK=64e6
fi
fi
awk '
/RX Dboard: / {side=$6; rxmode=1}
/TX Dboard: / {rxmode=0}
/ID: / {type=$5
if (rxmode == 1) printf ("SIDE_%s_TYPE=%s\n", side, type)
}
' tmp$$ >tmp2$$
. tmp2$$
rm -f tmp2$$
rm -f tmp$$
}
function set_card_params {
case $card_type in
WBX*)
F_LOW=50.0e6
F_HIGH=2.2e9
RCVR_CARD="WBX"
;;
DBS*)
F_LOW=900e6
F_HIGH=2.3e9
RCVR_CARD="DBSRX"
;;
TVRX)
F_LOW=50e6
F_HIGH=860e6
RCVR_CARD="TVRX"
;;
TVRX2)
F_LOW=50e6
F_HIGH=862e6
RCVR_CARD="TVRX2"
;;
SBX*)
F_LOW=400e6
F_HIGH=4.4e9
RCVR_CARD="SBX"
;;
RFX900)
F_LOW=800.0e6
F_HIGH=1.0e9
RCVR_CARD="RFX900"
;;
RFX1200)
F_LOW=1.15e9
F_HIGH=1.45e9
RCVR_CARD="RFX1200"
;;
RFX1800)
F_LOW=1.5e9
F_HIGH=2.05e9
RCVR_CARD="RFX1800"
;;
RFX2400)
F_LOW=2.3e9
F_HIGH=2.9e9
RCVR_CARD="RFX2400"
;;
Basic)
F_LOW=1.0e6
F_HIGH=50.0e6
RCVR_CARD="BASICRX"
if [ $RCVR_HW_TYPE = USRP1 ]
then
F_HIGH=32.0e6
fi
;;
LF*)
F_LOW=1.0e6
F_HIGH=30.0e6
RCVR_CARD="LFRX"
;;
esac
export F_LOW
export F_HIGH
export RCVR_CARD
}
function fifos {
cd $HOME/.rcvr_cfg
#
# Blow away existing FIFO files
#
rm -f ra_*fifo
#
# Make fresh ones!
#
for fifo in ra_seti_fifo ra_psr_fifo ra_inter_fifo ra_validation_fifo
do
mkfifo $fifo
done
}
export LANG=en_US.UTF-8
export LC_NUMERIC=en_US.UTF-8
MENU=False
if [ -x `which zenity` -a "@$1@" = "@Menu@" ]
then
MENU=True
fi
#
# Setup PATH
#
PATH=$PATH:/usr/local/bin:/opt/bin
#
# Determine PYTHONPATH for Gnu Radio
#
pythonpath
if [ $PYTHONPATH = unset ]
then
errordialog "Cannot find appropriate PYTHONPATH setting"
exit
fi
export PYTHONPATH
#
# Create .rcvr_cfg if necessary
#
if [ ! -d $HOME/.rcvr_cfg ]
then
mkdir $HOME/.rcvr_cfg
fi
cd $HOME/.rcvr_cfg
#
# Blow away core files
#
rm -f core.*
#
# Set defaults
#
DEFAULT_SUBDEV="A:0"
export RCVR_DATA_DIR=$HOME/astro_data
export RCVR_INITIAL_FREQ=1420.4058e6
export RCVR_RF_GAIN=65
export RCVR_DC_GAIN=5
export RCVR_DC_OFFSET=0
export RCVR_DECLINATION=-15.0
export RCVR_TP_INTEG=15
export RCVR_SPEC_INTEG=30
export RCVR_LONGITUDE=-76.02
export RCVR_SETI_SIZE=400000
export RCVR_TP_RATE=100
export RCVR_PSR_RATE=10000
export RCVR_SPEC_FFTSIZE=2048
export RCVR_SETI_INTEG=45
export RCVR_SIGMA_K=2.75
export RCVR_REF_MULT=1.0
export RCVR_MODE=single
export RCVR_BANDWIDTH=4000000
export RCVR_SIDE=A
export RCVR_COR_A=1.0
export RCVR_COR_B=1.0
export RCVR_NOTCH_SIZE=128
export RCVR_NOTCHES="1.0"
export RCVR_BINWIDTH=16
export RCVR_SUBDEV="A:0"
export RCVR_PHCORR=0.0
export RCVR_PDELAY=0.0
NCORES=`cat /proc/cpuinfo|grep core.id|wc -l`
NTHREADS=`expr $NCORES - 1`
GR_FFTW_NTHREADS=$NTHREADS
export GR_FFTW_NTHREADS
BMIPS=`cat /proc/cpuinfo|grep -i bogomips|tail -1|sed -e 's/.*: //'`
BMIPS=`echo $BMIPS|sed -e 's/\..*$//'`
MULTIPLIER=`expr $NCORES '*' $BMIPS '/' 1000`
DFILTSIZE=`expr $MULTIPLIER '*' 1500`
ulimit -c 2000000
#
# Get previous settings
#
if [ -f rcvr_param.pdump ]
then
. ./rcvr_param.pdump
fi
#
# Get previous startup settings
#
if [ -f rcvr_start_params ]
then
. ./rcvr_start_params
fi
starter=true
#
# Probe for hardware
#
probe
if [ $RCVR_HW_TYPE = none ]
then
errordialog "Could not find any usable USRP device"
exit
fi
export RCVR_HW_ADDR
export RCVR_HW_TYPE
export RCVR_HW_CLOCK
#
# Determine HELP prefix
#
help_prefix
export RCVR_HELP_PREFIX
#
# Invoke receiver starter application
#
rm -f receiver_no_start
receiver_start >/dev/null 2>&1
if [ @"$RCVR_SKY_FREQ"@ = @@ ]
then
RCVR_SKY_FREQ=$RCVR_INITIAL_FREQ
export RCVR_SKY_FREQ
fi
#
# Starter app uses a simple file to flag that user wants to exit without starting
# the receiver chain
#
if [ -f receiver_no_start ]
then
rm -f receiver_no_start
exit
fi
#
# Bring in startup parameters
#
if [ -f rcvr_start_params ]
then
. ./rcvr_start_params
fi
if [ $RCVR_HW_TYPE = USRP2 ]
then
RCVR_SUBDEV=$DEFAULT_SUBDEV
fi
if [ "$RCVR_SUBDEV" = "A:0" ]
then
card_type=$SIDE_A_TYPE
set_card_params
if [ $RCVR_CARD = "BASICRX" -o $RCVR_CARD = "LFRX" ]
then
RCVR_SUBDEV="A:A"
fi
if [ $RCVR_CARD = "TVRX2" ]
then
RCVR_SUBDEV="A:RX1"
fi
fi
if [ "$RCVR_SUBDEV" = "B:0" ]
then
card_type=$SIDE_B_TYPE
set_card_params
if [ $RCVR_CARD = "BASICRX" -o $RCVR_CARD = "LFRX" ]
then
RCVR_SUBDEV="B:A"
fi
if [ $RCVR_CARD = "TVRX2" ]
then
RCVR_SUBDEV="B:RX1"
fi
fi
if [ $RCVR_HW_TYPE = "USRP2" -o $RCVR_HW_TYPE = "B100" ]
then
RCVR_MODE=single
fi
if [ $RCVR_MODE = "interferometer" ]
then
if [ $RCVR_BANDWIDTH -gt 4000000 ]
then
errordialog "Selected bandwidth too high for interferometer mode"
exit
fi
card_type=$SIDE_A_TYPE
set_card_params
RCVR_SUBDEV="A:0 B:0"
if [ $RCVR_CARD = "BASICRX" -o $RCVR_CARD = "LFRX" ]
then
RCVR_SUBDEV="A:A B:A"
fi
card_type=$SIDE_A_TYPE
set_card_params
f1=$F_LOW
f2=$F_HIGH
card_type=$SIDE_B_TYPE
set_card_params
f3=$F_LOW
f4=$F_HIGH
overlap=`echo $f1 $f2 $f3 $f4|awk '
/./ {if ( $1 <= $4 && $3 <= $2 )
{
print "TRUE"
}
else
{
print "FALSE"
}
}
'`
if [ $overlap = FALSE ]
then
errordialog "Cards: $SIDE_A_TYPE and $SIDE_B_TYPE do not have overlapping frequency ranges"
exit
fi
F_LOW=`echo $f1 $f2 $f3 $f4|awk '
/./ {if ($1 <= $3)
{
print $3
}
else
{
print $1
}
}
'`
F_HIGH=`echo $f1 $f2 $f3 $f4|awk '
/./ {if ($2 <= $4)
{
print $2
}
else
{
print $4
}
}'`
export F_LOW
export F_HIGH
fi
#
# Data directory there already?
# If not, create it
#
if [ ! -d $RCVR_DATA_DIR ]
then
mkdir $RCVR_DATA_DIR
fi
#
# Adjust BINWIDTH based on BANDWIDTH
# We start out with the default 20Hz, and work our way downwards with
# lower BANDWIDTH
#
if [ $RCVR_BANDWIDTH -lt 10000000 ]
then
RCVR_BINWIDTH=8
fi
if [ $RCVR_BANDWIDTH -lt 5000000 ]
then
RCVR_BINWIDTH=4
fi
export RCVR_BINWIDTH
#
# Calculate size of SETI FFT
#
cat >tmp$$.py <<!EOF!
import sys
import math
bandwidth=float(sys.argv[1])
binwidth=float(sys.argv[2])
log2 = math.ceil(math.log(bandwidth/binwidth)/math.log(2))
log2 = int(log2)
print int(pow(2.0,log2))
!EOF!
RCVR_SETI_SIZE=`python tmp$$.py $RCVR_BANDWIDTH $RCVR_BINWIDTH`
rm -f tmp$$.py
export RCVR_SETI_SIZE
cd $HOME/.rcvr_cfg
#
# Establish required FIFOs, control files, etc
#
fifos
#
# Kill off any previous Gnu Radio script
#
if [ -s receiver.pid ]
then
kill `cat receiver.pid` >/dev/null 2>&1
fi
#
# Startup the IRA main control application in the background
# Starup the dtracker as well
#
nohup integrated_ra_receiver >/dev/null 2>receiver.log &
PID=$!
nohup dtracker >/dev/null 2>dtracker.log &
DPID=$!
#
# Arrange to kill off control app if this script is interrupted
#
trap 'kill -15 $PID; kill -15 $DPID; exit' \
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#
# Right now, we only support UHD single-channel mode
#
if [ $RCVR_MODE = "uhd" -o $RCVR_MODE = "single" ]
then
uhd_ra_receiver_new.py --freq $RCVR_INITIAL_FREQ --sky $RCVR_SKY_FREQ --gain $RCVR_RF_GAIN \
--bandwidth $RCVR_BANDWIDTH --subdev $RCVR_SUBDEV \
--ratepsr $RCVR_PSR_RATE --devaddr $RCVR_HW_ADDR --binwidth $RCVR_BINWIDTH \
--dm 1500.0 --setisize $RCVR_SETI_SIZE >receiver_py.log 2>receiver_py.err
elif [ $RCVR_MODE = "interferometer" ]
then
uhd_ra_interferometer.py --freq $RCVR_INITIAL_FREQ --sky $RCVR_SKY_FREQ --gain $RCVR_RF_GAIN \
--bandwidth $RCVR_BANDWIDTH --subdev "$RCVR_SUBDEV" --cora $RCVR_COR_A --corb $RCVR_COR_B \
--ratepsr $RCVR_PSR_RATE --devaddr type=usrp1 --binwidth $RCVR_BINWIDTH \
--dm 1500.0 --setisize $RCVR_SETI_SIZE --phcorr $RCVR_PHCORR \
--pdelay $RCVR_PDELAY >receiver_py.log 2>receiver_py.err
else
errordialog "Receiver starter asked for unsupported mode: $RCVR_MODE"
fi
#
# It should already be dead at this point, but let's make certain
#
killall integrated_ra_receiver dtracker >/dev/null 2>&1