Selaa lähdekoodia

moulte bugfix

Pierre Bourdin 1 vuosi sitten
vanhempi
commit
cb32d91955

+ 21 - 9
process/1_capture → acquisition_process/1_capture

@@ -1,7 +1,11 @@
 #!/bin/bash
 
+CONVERTLL_PATH="/home/pi/BallonSonde/convert_ll_dec.py"
+READ_NMEA_PATH="/home/pi/BallonSonde/read_nmea.py"
+
+echo "=> Acquisition on !"
 DATE=$(date +%y%m%d_%H%M%S)
-../read_nmea.py > /ramfs/.out
+$READ_NMEA_PATH > /ramfs/.out
 raspistill -o /ramfs/$DATE.jpg
 
 DATA=$(cat /ramfs/.out)
@@ -10,16 +14,16 @@ EW=$(echo $DATA| tr ' ' '\n' | grep EW | cut -d'=' -f2 | cut -d',' -f1)
 
 LAT=$(echo $DATA| tr ' ' '\n' | grep 'lat=' | cut -d'=' -f2 | cut -d',' -f1)
 echo "Latitude $LAT"
-LATD=$(../convert_ll_dec.py $LAT | grep "d:" | cut -d':' -f2)
-LATM=$(../convert_ll_dec.py $LAT | grep "m:" | cut -d':' -f2)
-LATS=$(../convert_ll_dec.py $LAT | grep "s:" | cut -d':' -f2 | sed 's/\.//' )
+LATD=$($CONVERTLL_PATH $LAT | grep "d:" | cut -d':' -f2)
+LATM=$($CONVERTLL_PATH $LAT | grep "m:" | cut -d':' -f2)
+LATS=$($CONVERTLL_PATH $LAT | grep "s:" | cut -d':' -f2 | sed 's/\.//' )
 echo "$LATD $LATM $LATS"
 
 LON=$(echo $DATA| tr ' ' '\n' | grep 'lon=' | cut -d'=' -f2 | cut -d',' -f1)
 echo "Longitude : $LON"
-LOND=$(../convert_ll_dec.py $LON| grep "d:" | cut -d':' -f2)
-LONM=$(../convert_ll_dec.py $LON | grep "m:" | cut -d':' -f2)
-LONS=$(../convert_ll_dec.py $LON | grep "s:" | cut -d':' -f2 | sed 's/\.//')
+LOND=$($CONVERTLL_PATH $LON| grep "d:" | cut -d':' -f2)
+LONM=$($CONVERTLL_PATH $LON | grep "m:" | cut -d':' -f2)
+LONS=$($CONVERTLL_PATH $LON | grep "s:" | cut -d':' -f2 | sed 's/\.//')
 echo "$LOND $LONM $LONS"
 
 # Creation du script pour ajout des données Exif dans le JPG
@@ -34,7 +38,15 @@ cat <<EOF > /ramfs/.conf_exif
     add Exif.GPSInfo.GPSLongitude ${LOND}/1 ${LONM}/1 ${LONS}/10000
 EOF
 
-exiv2 -m /ramfs/.conf_exif /ramfs/$DATE.jpg
+if [[ "$LAT" -ne "NO_DATA" ]]; then
+	exiv2 -m /ramfs/.conf_exif /ramfs/$DATE.jpg
+else
+	echo "Don't have GPS datas, continue without these datas"
+fi
+
 echo "Picz $DATE.jpg saved in RAM"
-cp /ramfs/$DATE.jpg ~/_Pictures
+mv /ramfs/$DATE.jpg ~/_Pictures
 echo "Picz $DATE.jpg saved to SDCARD"
+
+echo "$DATE.jpg" > /ramfs/.canbeconvert
+sleep 60

+ 15 - 1
convert_ll_dec.py

@@ -1,7 +1,21 @@
 #!/usr/bin/python3
 import sys
 
-deg = float(sys.argv[1])
+def error():
+    print("d:NO_DATA")
+    print("m:NO_DATA")
+    print("s:NO_DATA")
+    exit(1)
+
+
+if len(sys.argv) < 2:
+    error()
+
+try:
+    deg = float(sys.argv[1])
+except:
+    print("Can't convert it to float")
+    error()
 
 m, s = divmod(abs(deg)*3600, 60)
 d, m = divmod(m, 60)

+ 41 - 0
convert_process/2_convert

@@ -0,0 +1,41 @@
+#!/bin/bash
+
+#IMG=$(cd /ramfs; find ./ -type f -name *.jpg -exec readlink -f {} \;)
+#IMG=$(ls -t /home/pi/_Pictures | head -1)
+
+while [[ ! -f /ramfs/.canbeconvert ]]; do
+	sleep 1
+	echo "wait for file to convert..."
+done
+
+IMG=$(cat /ramfs/.canbeconvert)
+echo "=> File $IMG detected !"
+
+#############
+# Mode SSTV
+while [[ -f "/ramfs/totx.wav" ]]; do 
+	echo "=> Skipping convert, because old one is not yet Txed !"
+	sleep 5
+done
+
+# On traite l'image...
+echo "=> Copying picz in RAMFS"
+cp -r /home/pi/_Pictures/$IMG /ramfs/$IMG
+echo "=> Converting to PD120 Format <long>x496"
+convert /ramfs/$IMG -resize 660x496^ /ramfs/lit-$IMG
+rm -rf /ramfs/$IMG
+echo "=> Adding annotaion"
+mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 26 -gravity NorthEast -annotate +10+10 " $(date) - F4IYQ - 73 :o) " /ramfs/lit-$IMG
+
+echo " => Converting image to WAV..."
+cd ~/PySSTV/
+source bin/activate
+python -m pysstv --mode PD120 --rate 44100 --bits 16 --vox --fskid "F4IYQ" /ramfs/lit-$IMG /ramfs/totx.wav
+deactivate
+echo "=> Setting flag that can be Tx"
+touch /ramfs/.canbetx
+
+rm -rf /ramfs/lit-$IMG
+
+echo -n ""
+

BIN
mire.jpg


+ 0 - 7
process/0_start

@@ -1,7 +0,0 @@
-#!/bin/bash
-
-echo "=================================="
-echo "  Start Process - Ballon Sonde !"
-echo "=================================="
-
-

+ 0 - 9
process/2_convert

@@ -1,9 +0,0 @@
-#!/bin/bash
-
-echo " => Converting file in little format for Tx"
-cd /ramfs
-FILE=$(find ./ -type f -name *.jpg)
-convert $FILE -resize 640x496^ lit-$(echo $FILE | cut -d"/" -f2)
-rm -rf $FILE
-
-mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 26 -gravity NorthEast -annotate +10+10 "$(date) - F4IYQ - 73 ;)" *.jpg

+ 0 - 7
process/9_end

@@ -1,7 +0,0 @@
-#!/bin/bash
-
-echo "=================================="
-echo "See ya !" 
-echo "=================================="
-
-

+ 13 - 0
setup.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# Setup the basic configurations
+sudo cp -r sysconfig/config.txt /boot/
+
+sudo rm -rf /etc/alsa
+sudo ln -s /home/pi/BallonSonde/sysconfig/alsa/ /etc/
+
+sudo rm -rf /var/spool/cron/crontabs/pi
+sudo ln -s /home/pi/BallonSonde/sysconfig/pi /var/spool/cron/crontabs/
+sudo chown -R pi:crontab /var/spool/cron/crontabs/pi
+
+

BIN
sound/mire.wav


+ 10 - 0
start.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# To delay with the rest of the system
+
+
+#sleep 10
+while true
+do
+	run-parts ~/BallonSonde/process/
+done

+ 240 - 0
sysconfig/alsa/conf.d/50_aec.conf

@@ -0,0 +1,240 @@
+### ALSA virtual device which combines recording and playback loopback for AEC processing
+# https://github.com/sanebow/alsa-aec
+# sanebow@gmail.com
+# Version: 0.3 (20210506)
+
+defaults.pcm.aec.playback_hw.card defaults.pcm.card   # playback hw card 
+defaults.pcm.aec.playback_hw.rate 48000               # sample rate supported by the playback card
+defaults.pcm.aec.capture_hw.card defaults.pcm.card    # capture hw card
+defaults.pcm.aec.capture_hw.rate 16000                # sample rate supported by the capture card
+## you may also directly set some PCM device as playback and capture device
+defaults.pcm.aec.playback_pcm "playback_hw"      
+defaults.pcm.aec.capture_pcm "capture_hw"             
+defaults.pcm.aec.pre_loopidx 4    # loopback subdevice index for stream before aec processing
+defaults.pcm.aec.post_loopidx 5   # loopback subdevice index for stream after aec processing
+
+pcm.playback_hw {
+  @args [ CARD RATE ]
+  @args.CARD { 
+    type string 
+    default {
+      @func refer
+      name defaults.pcm.aec.playback_hw.card
+    }
+  }
+  @args.RATE {
+    type integer
+    default {
+      @func refer
+      name defaults.pcm.aec.playback_hw.rate
+    }
+  }
+  type plug
+  slave.rate "unchanged"
+  slave.pcm {
+    type rate
+    slave.rate $RATE
+    slave.pcm {
+      type dmix
+      ipc_key 10009
+      ipc_key_add_uid yes
+      slave {
+        pcm {@func concat strings [ "hw:" $CARD ] }
+      }
+    }
+  }
+}
+
+pcm.capture_hw {
+  @args [ CARD RATE ]
+  @args.CARD { 
+    type string 
+    default {
+      @func refer
+      name defaults.pcm.aec.capture_hw.card
+    }
+  }
+  @args.RATE {
+    type integer
+    default {
+      @func refer
+      name defaults.pcm.aec.capture_hw.rate
+    }
+  }
+  type rate
+  slave.rate $RATE
+  slave.pcm {
+    type dsnoop
+    ipc_key 20009
+    ipc_key_add_uid yes
+    slave {
+      pcm {@func concat strings [ "hw:" $CARD ] }
+      rate $RATE
+    }
+    bindings.0 0
+  }
+}
+
+pcm.loopback_out {
+  @args [ SUBDEVICE ]
+  @args.SUBDEVICE { type integer }
+  type empty
+  slave.pcm {
+    type hw
+    card "Loopback"
+    device 0
+    subdevice $SUBDEVICE
+    channels 1
+    rate 16000
+    format S16_LE
+  }
+}
+
+pcm.loopback_in {
+  @args [ SUBDEVICE ]
+  @args.SUBDEVICE { type integer }
+  type empty
+  slave.pcm {
+    type hw
+    card "Loopback"
+    device 1
+    subdevice $SUBDEVICE
+    channels 1
+    rate 16000
+    format S16_LE
+  }
+}
+
+# audio play to this device will be duplicated to hw (stereo) and loopback (mono)
+pcm.mloopplay {
+  @args [ PCM LOOPIDX ]
+  @args.PCM { 
+    type string 
+    default {
+      @func refer
+      name defaults.pcm.aec.playback_pcm
+    }
+  }
+  @args.LOOPIDX {
+    type integer
+    default 4 
+  }
+  type route
+  slave.pcm {
+    type multi
+    slaves.a.pcm $PCM
+    slaves.a.channels 2
+    slaves.b.pcm {  # loopback null sink
+      @func concat
+      strings [ "plug:loopback_out:" $LOOPIDX ]
+    }
+    slaves.b.channels 1
+    bindings.0 { slave a channel 0 }
+    bindings.1 { slave a channel 1 }
+    bindings.2 { slave b channel 0 }
+  }
+  slave.channels 3
+  ttable.0.0 1
+  ttable.1.1 1
+  ttable.0.2 0.5
+  ttable.1.2 0.5
+}
+
+# combine mic (ch 0) and loopback (ch 1) to single recording
+pcm.mlooprec {
+  @args [ PCM LOOPIDX ]
+  @args.PCM { 
+    type string 
+    default {
+      @func refer
+      name defaults.pcm.aec.capture_pcm
+    }
+  }
+  @args.LOOPIDX {
+    type integer
+    default 4 
+  }
+  type multi
+  slaves.a.pcm $PCM
+  slaves.a.channels 1
+  slaves.b.pcm {  # loopback capturing interface
+    type dsnoop   # to align with capture_hw, avoid PortAudio error
+    ipc_key 10099
+    slave.pcm {
+      @func concat
+      strings [ "loopback_in:" $LOOPIDX ]
+    }
+  }
+  slaves.b.channels 1
+  bindings.0 { slave a channel 0 }
+  bindings.1 { slave b channel 0 }
+}
+
+pcm.aec_internal {
+  @args [ CAPPCM PRELOOPIDX POSTLOOPIDX ]
+  @args.CAPPCM { 
+    type string 
+    default {
+      @func refer
+      name defaults.pcm.aec.capture_pcm
+    }
+  }
+  @args.PRELOOPIDX {
+    type integer
+    default {
+      @func refer
+      name defaults.pcm.aec.pre_loopidx
+    }
+  }
+  @args.POSTLOOPIDX {
+    type integer
+    default {
+      @func refer
+      name defaults.pcm.aec.post_loopidx
+    }
+  }
+  type asym
+  capture.pcm {  # -i for aec script
+    @func concat 
+    strings [ "mlooprec:" $CAPPCM "," $PRELOOPIDX ]
+  }  
+  playback.pcm {   # -o for aec script
+    @func concat
+    strings [ "loopback_out:" $POSTLOOPIDX ]
+  }
+}
+
+pcm.aec {
+  @args [ PLYPCM PRELOOPIDX POSTLOOPIDX ]
+  @args.PLYPCM { 
+    type string 
+    default {
+      @func refer
+      name defaults.pcm.aec.playback_pcm
+    }
+  }
+  @args.PRELOOPIDX {
+    type integer
+    default {
+      @func refer
+      name defaults.pcm.aec.pre_loopidx
+    }
+  }
+  @args.POSTLOOPIDX {
+    type integer
+    default {
+      @func refer
+      name defaults.pcm.aec.post_loopidx
+    }
+  }
+  type asym
+  playback.pcm {
+    @func concat 
+    strings [ "mloopplay:" $PLYPCM "," $PRELOOPIDX ]
+  }   
+  capture.pcm {
+    @func concat
+    strings [ "loopback_in:" $POSTLOOPIDX ]
+  }
+}
+

+ 91 - 0
sysconfig/config.txt

@@ -0,0 +1,91 @@
+# For more options and information see
+# http://rpf.io/configtxt
+# Some settings may impact device functionality. See link above for details
+
+dtoverlay=disable-bt
+dtoverlay=audremap,pins_12_13 # for pins 12 and 13
+#force_turbo=1
+enable_uart=1
+#core_freq=250
+
+# uncomment if you get no picture on HDMI for a default "safe" mode
+#hdmi_safe=1
+
+# uncomment the following to adjust overscan. Use positive numbers if console
+# goes off screen, and negative if there is too much border
+#overscan_left=16
+#overscan_right=16
+#overscan_top=16
+#overscan_bottom=16
+
+# uncomment to force a console size. By default it will be display's size minus
+# overscan.
+#framebuffer_width=1280
+#framebuffer_height=720
+
+# uncomment if hdmi display is not detected and composite is being output
+#hdmi_force_hotplug=1
+
+# uncomment to force a specific HDMI mode (this will force VGA)
+#hdmi_group=1
+#hdmi_mode=1
+
+# uncomment to force a HDMI mode rather than DVI. This can make audio work in
+# DMT (computer monitor) modes
+#hdmi_drive=2
+
+# uncomment to increase signal to HDMI, if you have interference, blanking, or
+# no display
+#config_hdmi_boost=4
+
+# uncomment for composite PAL
+#sdtv_mode=2
+
+#uncomment to overclock the arm. 700 MHz is the default.
+#arm_freq=1100
+#force_turbo=1
+#core_freq=450
+#over_voltage=6
+
+# Uncomment some or all of these to enable the optional hardware interfaces
+#dtparam=i2c_arm=on
+#dtparam=i2s=on
+#dtparam=spi=on
+
+# Uncomment this to enable infrared communication.
+#dtoverlay=gpio-ir,gpio_pin=17
+#dtoverlay=gpio-ir-tx,gpio_pin=18
+
+# Additional overlays and parameters are documented /boot/overlays/README
+
+# Enable audio (loads snd_bcm2835)
+dtparam=audio=on
+
+# Automatically load overlays for detected cameras
+start_x=1
+
+# Automatically load overlays for detected DSI displays
+display_auto_detect=1
+
+# Enable DRM VC4 V3D driver
+#dtoverlay=vc4-kms-v3d
+max_framebuffers=2
+
+# Disable compensation for displays with overscan
+disable_overscan=1
+
+[cm4]
+# Enable host mode on the 2711 built-in XHCI USB controller.
+# This line should be removed if the legacy DWC2 controller is required
+# (e.g. for USB device mode) or if USB support is not required.
+otg_mode=1
+
+[all]
+
+[pi4]
+dtoverlay=vc4-fkms-v3d
+# Run as fast as firmware / board allows
+arm_boost=1
+
+[all]
+gpu_mem=128

+ 29 - 0
sysconfig/pi

@@ -0,0 +1,29 @@
+# DO NOT EDIT THIS FILE - edit the master and reinstall.
+# (/tmp/crontab.tkpyOg/crontab installed on Mon Sep 11 13:01:07 2023)
+# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
+# Edit this file to introduce tasks to be run by cron.
+# 
+# Each task to run has to be defined through a single line
+# indicating with different fields when the task will be run
+# and what command to run for the task
+# 
+# To define the time you can provide concrete values for
+# minute (m), hour (h), day of month (dom), month (mon),
+# and day of week (dow) or use '*' in these fields (for 'any').
+# 
+# Notice that tasks will be started based on the cron's system
+# daemon's notion of time and timezones.
+# 
+# Output of the crontab jobs (including errors) is sent through
+# email to the user the crontab file belongs to (unless redirected).
+# 
+# For example, you can run a backup of all your user accounts
+# at 5 a.m every week with:
+# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
+# 
+# For more information see the manual pages of crontab(5) and cron(8)
+# 
+# m h  dom mon dow   command
+
+@reboot	~/BallonSonde/active_nmea.py
+@reboot ~/BallonSonde/start.sh

+ 17 - 0
tx_process/0_txmire

@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# Setup the GPIO4 as output for Tx
+raspi-gpio set 4 op && raspi-gpio set 4 dh
+
+raspi-gpio set 4 dl
+sleep 1
+echo " => Playing WAV file"
+cd ~/trxamadrmv3_7/linux
+./txwfal 0
+sleep 1
+aplay ~/BallonSonde/sound/annonce_start.wav
+sleep 1
+aplay ~/BallonSonde/sound/mire.wav
+sleep 1
+aplay ~/BallonSonde/sound/annonce_stop.wav
+raspi-gpio set 4 dh

+ 14 - 21
process/3_transmit → tx_process/3_transmit

@@ -1,5 +1,15 @@
 #!/bin/bash
 
+if [ ! -f /ramfs/.canbetx ]; then
+	echo "Nothing to transmit, wait 5 seconds"
+	sleep 5
+	exit 1
+fi
+
+rm /ramfs/.canbetx
+echo "=> moving totx.wav to out.wav"
+mv /ramfs/totx.wav /ramfs/out.wav
+
 # Utile pour couper le TX quand on ctrl+c et que le script n'abouti pas
 trap ctrl_c INT
 function ctrl_c() {
@@ -11,20 +21,9 @@ function ctrl_c() {
 # Setup the GPIO4 as output for Tx
 raspi-gpio set 4 op && raspi-gpio set 4 dh
 
-IMG=$(cd /ramfs; find ./ -type f -name *.jpg -exec readlink -f {} \;)
-
-#############
-# Mode SSTV
-echo " => Converting image to WAV..."
-cd ~/PySSTV/
-source bin/activate
-python -m pysstv --mode PD120 $IMG /ramfs/out.wav
-deactivate
-
 raspi-gpio set 4 dl
 sleep 1
 echo " => Playing WAV file"
- TXT_TO_WFALL
 cd ~/trxamadrmv3_7/linux
 ./txwfal 0
 sleep 1
@@ -34,13 +33,7 @@ aplay /ramfs/out.wav
 aplay ~/BallonSonde/sound/annonce_stop.wav
 raspi-gpio set 4 dh
 
-
-#############
-# Mode DRM
-#cd ~/trxamadrmv3_7/linux/
-#./drm $IMG
-#raspi-gpio set 4 dh
-
-
-echo " => All done, cleaning ramfs"
-rm -rf /ramfs/*
+if [[ -f /ramfs/out.wav ]]; then
+	echo " => All done, cleaning ramfs"
+	rm -rf /ramfs/out.wav
+fi