Script pour beacon wspr headless

Projet: Réaliser une station de décodage wspr sans affichage graphique pour un serveur.

1.Installation des outils nécessaires:

sudo apt-get install python sed awk git alsa-utils

2.Le script

Attention, j’utilise arecord_adv voir article sur comment modifier arecord pour > 192khz. Vous pouvez utiliser arecord à la place si vous n’êtes qu’en 192khz.

#!/bin/bash

function usage(){
	printf "Utilisation du script :\n"
	printf "$0 alsa_device centerfreq freq band samplerate\n"
	printf "Example :\n"
	printf "$0 dsnoop:lp4,1 3568600 3568600 80m 384000 F4HTB JN38tg\n"
}

if [ $# -ne 7 ]
then
	usage
	exit 1
fi

alsa_device=$1
centerfreq=$2
freq=$3
band=$4
samplerate=$5
call=$6
grid=$7

pathwspr=/dev/shm/wspr_$band

rm -rf $pathwspr >/dev/null 2>&1
mkdir -p $pathwspr >/dev/null 2>&1

echo "Wait for time is sync"
wait_0 () {
	while [[ ("$(( $(date +"%_M") % 2))" -ne 0 ) || ("$(( $(date +"%_S")))" -ne 0 ) ]]
	do
		sleep 1
	done
}

if [ $freq -eq $centerfreq ]
then
	while true
	do
		wait_0
		now=$(date +"%y%m%d_%H%M")
		echo "Start for $now on $band"
		arecord_adv -q -d 118 -f S16_LE -r $samplerate -c2 -D $alsa_device -F0 --period-size=1024 -B0 --buffer-size=4096 | csdr convert_s16_f  | csdr fir_decimate_cc `python -c "print float($samplerate/12000)"` 0.05 HAMMING 2>/dev/null | csdr bandpass_fir_fft_cc 0 0.5 0.05 2>/dev/null | csdr realpart_cf | csdr gain_ff 20 | csdr convert_f_s16 | sox -q -t raw -b 16 -e signed -c 1 -r 12000 - -t wav $pathwspr/$now.wav
		wsprd -a $pathwspr -d -w -f  `python -c "print '%.6f'%($freq/1000000.0)"` $pathwspr/$now.wav | grep -v "DecodeFinished" | cut -f 2- -d ' '| awk -v date=$now '{print date," ",$0}' >>spots_$band && rm -rf $pathwspr/$now.wav && [ ! -f $pathwspr/wspr_spots.txt ] || [ ! -s $pathwspr/wspr_spots.txt ] || curl --silent -F allmept=@"$pathwspr/wspr_spots.txt" -F call=$call -F grid=$grid http://wsprnet.org/meptspots.php | grep "added" && rm -rf $pathwspr/wspr_spots.txt &
	done
fi

if [ $freq -ne $centerfreq ]
then
	while true
	do
		wait_0
		now=$(date +"%y%m%d_%H%M")
		echo "Start for $now on $band"
		arecord_adv -q -d 118 -f S16_LE -r384000 -c2 -D $alsa_device -F0 --period-size=1024 -B0 --buffer-size=4096 | csdr convert_s16_f  | csdr shift_addition_cc `python -c "print float($centerfreq-$freq)/$samplerate"` 2>/dev/null | csdr fir_decimate_cc `python -c "print float($samplerate/12000)"` 0.05 HAMMING 2>/dev/null | csdr bandpass_fir_fft_cc 0 0.5 0.05 2>/dev/null | csdr realpart_cf | csdr gain_ff 20 | csdr convert_f_s16 | sox -q -t raw -b 16 -e signed -c 1 -r 12000 - -t wav $pathwspr/$now.wav
		wsprd -a $pathwspr -d -w -f  `python -c "print '%.6f'%($freq/1000000.0)"` $pathwspr/$now.wav | grep -v "DecodeFinished" | cut -f 2- -d ' '| awk -v date=$now '{print date," ",$0}' >>spots_$band && rm -rf $pathwspr/$now.wav && [ ! -f $pathwspr/wspr_spots.txt ] || [ ! -s $pathwspr/wspr_spots.txt ] || curl --silent -F allmept=@"$pathwspr/wspr_spots.txt" -F call=$call -F grid=$grid http://wsprnet.org/meptspots.php | grep "added" && rm -rf $pathwspr/wspr_spots.txt &
	done
fi

 

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.