Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

receive.sh 3.1 KiB

há 4 anos
há 6 anos
há 6 anos
há 6 anos
há 6 anos
há 6 anos
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. ## import common lib
  3. . "$HOME/.noaa.conf"
  4. . "$HOME/.tweepy.conf"
  5. . "$NOAA_HOME/common.sh"
  6. ## pass start timestamp and sun elevation
  7. PASS_START=$(expr "$5" + 90)
  8. SUN_ELEV=$(python3 "$NOAA_HOME"/sun.py "$PASS_START")
  9. if pgrep "rtl_fm" > /dev/null
  10. then
  11. log "There is an existing rtl_fm instance running, I quit" "ERROR"
  12. exit 1
  13. fi
  14. # $1 = Satellite Name
  15. # $2 = Frequency
  16. # $3 = FileName base
  17. # $4 = TLE File
  18. # $5 = EPOC start time
  19. # $6 = Time to capture
  20. # $7 = Satellite max elevation
  21. log "Starting rtl_fm record" "INFO"
  22. timeout "${6}" /usr/local/bin/rtl_fm ${BIAS_TEE} -f "${2}"M -s 60k -g 50 -E wav -E deemp -F 9 - | /usr/bin/sox -t raw -e signed -c 1 -b 16 -r 60000 - "${RAMFS_AUDIO}/audio/${3}.wav" rate 11025
  23. if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then
  24. ENHANCEMENTS="ZA MCIR MCIR-precip MSA MSA-precip HVC-precip HVCT-precip HVC HVCT"
  25. daylight="true"
  26. else
  27. ENHANCEMENTS="ZA MCIR MCIR-precip"
  28. daylight="false"
  29. fi
  30. log "Bulding pass map" "INFO"
  31. /usr/local/bin/wxmap -T "${1}" -H "${4}" -p 0 -l 0 -o "${PASS_START}" "${NOAA_HOME}/map/${3}-map.png"
  32. for i in $ENHANCEMENTS; do
  33. log "Decoding image" "INFO"
  34. /usr/local/bin/wxtoimg -o -m "${NOAA_HOME}/map/${3}-map.png" -e "$i" "${RAMFS_AUDIO}/audio/${3}.wav" "${NOAA_OUTPUT}/images/${3}-$i.jpg"
  35. /usr/bin/convert -quality 90 -format jpg "${NOAA_OUTPUT}/images/${3}-$i.jpg" -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} $i ${START_DATE}Elev: $7°" "${NOAA_OUTPUT}/images/${3}-$i.jpg"
  36. /usr/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-$i.jpg" "${NOAA_OUTPUT}/images/thumb/${3}-$i.jpg"
  37. done
  38. if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then
  39. sqlite3 /home/pi/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($5,\"$3\", 1,1);"
  40. else
  41. sqlite3 /home/pi/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($5,\"$3\", 0,1);"
  42. fi
  43. pass_id=$(sqlite3 /home/pi/raspberry-noaa/panel.db "select id from decoded_passes order by id desc limit 1;")
  44. if [ -n "$CONSUMER_KEY" ]; then
  45. log "Posting to Twitter" "INFO"
  46. if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then
  47. python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE} Mas imagenes: https://weather.reyni.co/detail.php?id=$pass_id" "$7" "${NOAA_OUTPUT}/images/$3-MCIR-precip.jpg" "${NOAA_OUTPUT}/images/$3-MSA-precip.jpg" "${NOAA_OUTPUT}/images/$3-HVC-precip.jpg" "${NOAA_OUTPUT}/images/$3-HVCT-precip.jpg"
  48. else
  49. python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE} Mas imagenes: https://weather.reyni.co/detail.php?id=$pass_id" "$7" "${NOAA_OUTPUT}/images/$3-MCIR-precip.jpg" "${NOAA_OUTPUT}/images/$3-MCIR.jpg"
  50. fi
  51. fi
  52. sqlite3 /home/pi/raspberry-noaa/panel.db "update predict_passes set is_active = 0 where (predict_passes.pass_start) in (select predict_passes.pass_start from predict_passes inner join decoded_passes on predict_passes.pass_start = decoded_passes.pass_start where decoded_passes.id = $pass_id);"
  53. if [ "$DELETE_AUDIO" = true ]; then
  54. log "Deleting audio files" "INFO"
  55. rm "${RAMFS_AUDIO}/audio/${3}.wav"
  56. else
  57. log "Moving audio files out to the SD card" "INFO"
  58. mv "${RAMFS_AUDIO}/audio/${3}.wav" "${NOAA_OUTPUT}/audio/${3}.wav"
  59. fi