forked from reynico/raspberry-noaa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
receive_meteor.sh.online
executable file
·157 lines (120 loc) · 5.81 KB
/
receive_meteor.sh.online
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
#!/bin/sh
## debug
# set -x
. ~/.noaa.conf
## sane checks
if [ ! -d ${NOAA_HOME} ]; then
mkdir -p ${NOAA_HOME}
fi
if [ ! -d ${NOAA_OUTPUT} ]; then
mkdir -p ${NOAA_OUTPUT}
fi
if [ ! -d ${NOAA_AUDIO}/audio/ ]; then
mkdir -p ${NOAA_AUDIO}/audio/
fi
if [ ! -d ${NOAA_OUTPUT}/image/ ]; then
mkdir -p ${NOAA_OUTPUT}/image/
fi
if [ ! -d ${NOAA_HOME}/map/ ]; then
mkdir -p ${NOAA_HOME}/map/
fi
if [ ! -d ${NOAA_HOME}/predict/ ]; then
mkdir -p ${NOAA_HOME}/predict/
fi
#if pgrep "rtl_fm" > /dev/null
#then
# exit 1
#fi
# $1 = Satellite Name
# $2 = Frequency
# $3 = FileName base
# $4 = TLE File
# $5 = EPOC start time
# $6 = Time to capture
# $7 = Satellite max elevation
# Close STDOUT file descriptor
exec 1<&-
# Close STDERR FD
exec 2<&-
LOGFILE=${NOAA_AUDIO}/${3}
# Open STDOUT as $LOG_FILE file for read and write.
exec 1<>${LOGFILE}.log
exec 2<>${LOGFILE}.err
PASS_START=$(expr "$5" + 90)
SUN_ELEV=$(python2 ${NOAA_HOME}/sun.py $PASS_START)
if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then
echo "SUN ELEV: ${SUN_ELEV} OK "
else
echo "SUN ELEV: ${SUN_ELEV} too low "
# exit 0
fi
START_DATE=$(date '+%d-%m-%Y %H:%M')
FOLDER_DATE="$(date +%Y)/$(date +%m)/$(date +%d)"
/usr/bin/pkill rtl_fm
sleep 1
if [ ! -d ${NOAA_OUTPUT}/image/${FOLDER_DATE} ]; then
mkdir -p ${NOAA_OUTPUT}/image/${FOLDER_DATE}
fi
if [ ! -d ${NOAA_OUTPUT}/meteor_raw/${FOLDER_DATE} ]; then
mkdir -p ${NOAA_OUTPUT}/meteor_raw/${FOLDER_DATE}
fi
#mount /dev/sda1 /usbstick
#timeout "${6}" /usr/bin/rtl_sdr -g "${RECEIVE_GAIN}" -f "${2}"M /usbstick/"${3}".raw
#exit 0
rm -f /tmp/meteor_iq
echo mkfifo /tmp/meteor_iq
mkfifo /tmp/meteor_iq
echo nice -n 10 /usr/bin/meteor_demod -B -R 1000 -b 80 -s 180k /tmp/meteor_iq -o "${NOAA_AUDIO}/${3}.qpsk"
nice -n 10 /usr/bin/meteor_demod -B -R 1000 -b 80 -s 180k /tmp/meteor_iq -o "${NOAA_AUDIO}/${3}.qpsk" &
exec 3<> /tmp/meteor_iq
echo fnctl
/usr/bin/perl -MFcntl -e 'fcntl(STDOUT, 1031, 1048576000)'>/tmp/meteor_iq
echo timeout ${6} /usr/bin/rtl_fm -M raw -s 180k -f "${2}"M -E dc -g "${RECEIVE_GAIN}" /tmp/meteor_iq
#timeout ${6} /usr/bin/rtl_fm -M raw -s 180k -f "${2}"M -E dc -g "${RECEIVE_GAIN}" /tmp/meteor_iq
timeout ${6} /usr/bin/rtl_fm -M raw -s 180k -f "${2}"M -E dc -g 16 /tmp/meteor_iq
exec 3>&-
while [ `/usr/bin/pgrep -c meteor_demod` -ne "0" ]; do sleep 1; done
echo rm -f /tmp/meteor_iq
rm -f /tmp/meteor_iq
echo /usr/bin/nice -n 10 /usr/bin/medet_arm "${NOAA_AUDIO}/${3}.qpsk" "${NOAA_OUTPUT}/meteor_raw/${FOLDER_DATE}/${3}" -cd -na
/usr/bin/nice -n 10 /usr/bin/medet_arm "${NOAA_AUDIO}/${3}.qpsk" "${NOAA_OUTPUT}/meteor_raw/${FOLDER_DATE}/${3}" -cd -na
echo rm "${NOAA_AUDIO}/${3}.qpsk"
rm "${NOAA_AUDIO}/${3}.qpsk"
echo /usr/bin/scp "${NOAA_OUTPUT}/meteor_raw/${FOLDER_DATE}/${3}.dec" hjf@cloudserver:lri/watchdir/
/usr/bin/scp "${NOAA_OUTPUT}/meteor_raw/${FOLDER_DATE}/${3}.dec" hjf@cloudserver:lri/watchdir/
sleep 2
echo /usr/bin/ssh hjf@cloudserver "/home/hjf/lri/lrpt.pl /home/hjf/lri/watchdir/${3}.dec"
/usr/bin/ssh hjf@cloudserver "/home/hjf/lri/lrpt.pl /home/hjf/lri/watchdir/${3}.dec"
res=$?
echo resultado $res
if [ "${res}" -eq 0 ]; then
exit 0
fi
echo /usr/bin/nice -n 10 /usr/bin/medet_arm "${NOAA_OUTPUT}/meteor_raw/${FOLDER_DATE}/${3}.dec" "${NOAA_AUDIO}/${3}_122" -r 65 -g 65 -b 64 -d
/usr/bin/nice -n 10 /usr/bin/medet_arm "${NOAA_OUTPUT}/meteor_raw/${FOLDER_DATE}/${3}.dec" "${NOAA_AUDIO}/${3}_122" -r 65 -g 65 -b 64 -d -na -t
echo /usr/bin/nice -n 10 /usr/bin/medet_arm "${NOAA_OUTPUT}/meteor_raw/${FOLDER_DATE}/${3}.dec" "${NOAA_AUDIO}/${3}_122" -r 65 -g 65 -b 64 -d
/usr/bin/nice -n 10 /usr/bin/medet_arm "${NOAA_OUTPUT}/meteor_raw/${FOLDER_DATE}/${3}.dec" "${NOAA_AUDIO}/${3}_IR" -r 68 -g 68 -b 68 -d -na -t
echo /home/pi/meteor_rectify/rectify.py "${NOAA_AUDIO}/${3}_122.bmp"
/home/pi/meteor_rectify/rectify.py "${NOAA_AUDIO}/${3}_122.bmp"
echo /home/pi/meteor_rectify/rectify.py "${NOAA_AUDIO}/${3}_IR.bmp"
/home/pi/meteor_rectify/rectify.py "${NOAA_AUDIO}/${3}_IR.bmp"
echo /usr/bin/convert -quality 90 -format jpg "${NOAA_AUDIO}/${3}_122-rectified.png" -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} $i ${START_DATE}" ${NOAA_OUTPUT}/image/${FOLDER_DATE}/"${3}_122".jpg
/usr/bin/convert -quality 90 -format jpg "${NOAA_AUDIO}/${3}_122-rectified.png" -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} $i ${START_DATE}" ${NOAA_OUTPUT}/image/${FOLDER_DATE}/"${3}_122".jpg
echo /usr/bin/convert -quality 90 -format jpg "${NOAA_AUDIO}/${3}_IR-rectified.png" -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} $i ${START_DATE}" ${NOAA_OUTPUT}/image/${FOLDER_DATE}/"${3}_IR".jpg
/usr/bin/convert -quality 90 -format jpg "${NOAA_AUDIO}/${3}_IR-rectified.png" -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} $i ${START_DATE}" ${NOAA_OUTPUT}/image/${FOLDER_DATE}/"${3}".jpg
echo rm "${NOAA_AUDIO}/${3}_122.bmp"
rm "${NOAA_AUDIO}/${3}_122.bmp"
echo rm "${NOAA_AUDIO}/${3}_122-rectified.png"
rm "${NOAA_AUDIO}/${3}_122-rectified.png"
echo rm "${NOAA_AUDIO}/${3}_IR.bmp"
rm "${NOAA_AUDIO}/${3}_IR.bmp"
echo rm "${NOAA_AUDIO}/${3}_IR-rectified.png"
rm "${NOAA_AUDIO}/${3}_IR-rectified.png"
if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then
echo /usr/bin/python3 ${NOAA_HOME}/tpost.py ${TELEGRAM_TOKEN} ${TELEGRAM_CHAT_ID} ${NOAA_OUTPUT}/image/${FOLDER_DATE}/"${3}".jpg "Meteor M2 False Color. MEL ${7}"
/usr/bin/python3 ${NOAA_HOME}/tpost.py ${TELEGRAM_TOKEN} ${TELEGRAM_CHAT_ID} ${NOAA_OUTPUT}/image/${FOLDER_DATE}/"${3}_122".jpg "Meteor M2 False Color. MEL ${7}"
else
echo /usr/bin/python3 ${NOAA_HOME}/tpost.py ${TELEGRAM_TOKEN} ${TELEGRAM_CHAT_ID} ${NOAA_OUTPUT}/image/${FOLDER_DATE}/"${3}_IR".jpg "Meteor M2 IR MEL ${7}"
/usr/bin/python3 ${NOAA_HOME}/tpost.py ${TELEGRAM_TOKEN} ${TELEGRAM_CHAT_ID} ${NOAA_OUTPUT}/image/${FOLDER_DATE}/"${3}".jpg "Meteor M2 IR. MEL ${7}"
fi
#rm ${NOAA_AUDIO}/audio/*