#!/bin/bash #Ebnaut autodecoder # IZ7SLZ Oct. 2020 # subroutines function update_log { FOUND=$(grep -c 'found' DECODED1.TXT) ## instructions for updating the report log (header.txt contains the page title with callsign, etc..) echo $(date -R -u) > data.txt if [ $FOUND \> 0 ] ; then #only if decodes are found cat DECODEDOLD.TXT > tmp cat DECODED2.TXT tmp > DECODEDOLD.TXT rm tmp ## instructions to generate Marku's phase plots and adding decode's text. cat rawsyms > rawsyms.txt cat mytext.txt DECODED3.TXT > DECODED4.TXT timeout -k 1s 20 wine show_rawsyms3b.exe & sleep 10 import -window 'show_rawsyms3b' img1.png convert -pointsize 10 -fill white -draw @DECODED4.TXT -quality 100% img1.png img.jpg cp img.jpg EbNaut_plots/$(date +%y%m%d_%H%M).jpg # collects plots in a folder if [ $UPLOAD = 1 ]; then curl -v -T "{img.jpg}" ftp://user:password@ftp.qsl.net/EBNAUT/ #upload to qsl.net fi rm DECODED4.TXT fi cat data.txt header.txt DECODEDOLD.TXT > DECODED.TXT #delete all temp files rm DECODED3.TXT rm DECODED2.TXT rm DECODED1.TXT if [ $UPLOAD = 1 ]; then #invoke shell file with curl for upload files to website curl -v -T "{DECODED.TXT}" ftp://user:password@ftp.qsl.net/EBNAUT/ #upload to qsl.net fi } function process_decode { clear echo echo echo 'processing '$TIMESLOT ' +'$REC 'seconds....' echo '=======================================================================' echo $TIMESLOT $FREQUENCY'Hz N='$CHAR 'T='$SYM's' $CODE 'CRC='$CRC 'list='$LIST 'sym='$BITS 'Duration='$DURAT's ' > DECODED1.TXT echo 'T_OFFSET='$T_OFFSET's' 'F_OFFSET='$F_OFFSET'Hz' 'BLANKER A_FACT='$A_BLANKER >> DECODED1.TXT vtread -v -T $TIMEINIT,'+'$REC /run/user/1000/gvfs/smb-share:server=192.168.0.17,share=$FOLDER | # read LF raw vtcat -p | vtfilter -v -h bp,f=$FREQ,w=2000 | # Pre-filter before blanking vtblank -v -a$A_BLANKER -d0.00 -t100 | # sferic blanker settings vtmult -v -f $FREQ | # Mix to baseband I/Q vtresample -v -r 240 | # Reduce to 240 sample pairs/sec vtraw -oa | # Convert to 3-columns of ASCII ebnaut -v -dp$CODE -F$F_OFFSET -N$CHAR -S$SYM -r240 -k$CRC -c4 -L$LIST -T$DELAY -$PHASE $MSG 2>&1 | tee -a DECODED1.TXT # Decode 2>&1 manda stdout e stderr su schermo e file: -vv fornisce tutte le info echo ------------------------------------------------------------------------------------------ >> DECODED1.TXT sed '/^phase\|skipped\|elapsed\|initial\|Es\|vstack:/d' DECODED1.TXT > DECODED2.TXT #erase lines not necessary in the log sed '/^phase\|skipped\|carrier\|elapsed\|initial\|vstack:/d' DECODED1.TXT > DECODED3.TXT #erase lines not necessary the the text of the plot update_log } ############################################################## #### MAIN PROGRAM ### enter working parameters FREQUENCY=137477.000 DIAL=136000 LIST=10000 CHAR=30 SYM=1 CRC=16 RATE=8 CONSTR=19 T_OFFSET=0.0 F_OFFSET=0.0000 A_BLANKER=25 PHASE="PS" #PHASE="PU" #PHASE="PS15" # MSG="-f15 -f16 -M '******************************'" FOLDER="lf" #declare subfolder of the storage drive PERIOD=1800 #declare period (seconds) UPLOAD=1 # put 1 if upload to websites is required REPEAT=1000 #declare number of timeslots to decode. Put REPEAT=1 to make only 1 decode process. After REPEAT times, the program does exit. #INITIAL CALCULATIONS ##################### CALCULATE FIRST TIMESLOT TO DECODE AFTER PROGRAM START dataepo=$(date -u +%s) multip=$(echo $(date -u +%s)/$PERIOD | bc -l) multip=$(echo "($multip)/1" | bc) data2epo=$(echo $multip*$PERIOD | bc -l) TX_DATA=$(date -d @$data2epo -u +%Y-%m-%d) TX_ORA=$(date -d @$data2epo -u +%H:%M:%S) # ... OR YOU CAN SET here MANUALLY THE FIRTS TIMESLOT TO DECODE #TX_DATA='2021-03-24' #TX_ORA='05:30:00' TX_TIME=$TX_DATA' '$TX_ORA #utc first transmission ########################### T1=$(date -d "${TX_TIME}" -u +%s) # first tx time start in epoch TIMEINIT=$(echo $T1-60 | bc -l) #initial time 60s early (in epoch) CODE=$RATE'K'$CONSTR'A' FREQ=$(echo $FREQUENCY-$DIAL | bc -l) BITS=$(echo $CHAR*6+$CRC+$CONSTR-1 | bc -l) BITS=$(echo $BITS*$RATE | bc -l) # no. of symbols DURAT=$(echo $BITS*$SYM | bc -l) # duration of the transmission REC=$(echo $DURAT+ 63 | bc -l) # duration of the raw data to retrieve (duration + 60s before + 3s after) DELAY=$(echo $T_OFFSET+ 60 | bc -l) # time offset for decoding FINAL_FREQ=$(echo $FREQUENCY+$F_OFFSET | bc -l) T2=$(echo $DURAT+$T1+15 | bc -l) # TIME START OF FIRST DECODING PROCESS (end of the first transmission + 15s latency for vttime) T2=$(echo "($T2)/1" | bc) # keep $T2 integer clear # LOOP while true; do ora=$(date +%Y-%m-%d)' '$(date +%H:%M:%S) #now in ISO format ora=$(date -d "${ora}" +%s) # now in epoch if [ $ora -gt $T2 ]; then # it's time to start decoding TIMEINIT=$(echo $T1-60 | bc -l) #initial time 60s early (in epoch) TIMESLOT=$(date -d @"${T1}" -u +%Y-%m-%d)' '$(date -d @"${T1}" -u +%H:%M:%S) #formato ISO T1=$(echo $T1+$PERIOD | bc -l) #set next timeslot (epoch) T2=$(echo $T2+$PERIOD | bc -l) #set next decoding start (epoch) process_decode # call decoding routine REPEAT=$(echo $REPEAT-1 | bc -l) # countdown for the number of decoding sessions if [ $REPEAT = 0 ]; then exit # exit program when all decoding sessions are done fi fi sleep 0.5 done