I trying to employ my RTL-SDR to listen to the radio and got an AI program produced to find and play stations with a strong signal.
Here is what it came up with:-
Unfortunately the line
if [ "$(echo "$power > $SQUELCH" | bc -l)" -eq 1 ]; then
dumps with a floating point exception.
Is this line correctly created?
How would I run it from a command prompt using values of 99 and 25 for $power an $SQUELCH ?
Here is what it came up with:-
sh:
#!/bin/sh
# ====================== CONFIGURATION ======================
MIN_FREQ=88.0
MAX_FREQ=108.0
STEP=0.1
GAIN=40
SQUELCH=-25
LISTEN_TIME=12
# ===========================================================
echo "FM Strong Station Player (FreeBSD)"
echo "Squelch: $SQUELCH dB | Gain: $GAIN"
echo "Press Ctrl+C to stop"
echo
freq=$MIN_FREQ
while [ "$(echo "$freq <= $MAX_FREQ" | bc -l)" -eq 1 ]; do
# Measure signal power
power=$(rtl_power -f ${freq}M:${freq}M:10k -g $GAIN -i 0.3 -e 1s 2>/dev/null | \
awk -F',' '{s+=$6; n++} END {if(n>0) printf "%.1f", s/n; else print -99}')
printf "\r→ %6.1f MHz Power: %6.1f dB" "$freq" "$power"
# Squelch check
if [ "$(echo "$power > $SQUELCH" | bc -l)" -eq 1 ]; then
echo
echo
echo ">>> Strong station found: ${freq} MHz ($power dB)"
echo "Playing for $LISTEN_TIME seconds..."
# Play station
rtl_fm -f ${freq}M -M wbfm -s 200k -r 32k -g $GAIN -l 15 2>/dev/null | \
play -r 32k -t raw -e signed-integer -b 16 -c 1 - 2>/dev/null &
play_pid=$!
sleep "$LISTEN_TIME"
kill $play_pid 2>/dev/null
wait $play_pid 2>/dev/null
echo "----------------------------------------"
fi
# Increase frequency
freq=$(echo "$freq + $STEP" | bc -l)
done
echo
echo "Scan finished."
Unfortunately the line
if [ "$(echo "$power > $SQUELCH" | bc -l)" -eq 1 ]; then
dumps with a floating point exception.
Is this line correctly created?
How would I run it from a command prompt using values of 99 and 25 for $power an $SQUELCH ?