Fix configuration and scripts

This commit is contained in:
Satu Koskinen 2022-10-04 21:12:00 +03:00
parent 8f398e90de
commit a8ebf389fb
8 changed files with 27 additions and 20 deletions

View File

@ -1,21 +1,21 @@
# Audio
SAMPLE_RATE="44100"
CHANNELS="2"
SAMPLE_RATE=44100
CHANNELS=2
BITRATE="192k"
BATCH_RECORD_LENGTH="60"
BATCH_RECORD_LENGTH=60
# GPS
GPS_INTERVAL="5"
GPS_INTERVAL=5
# Depth
DEPTH_INTERVAL="5"
DEPTH_INTERVAL=5
# Output location
TRY_MOUNT_SSD="true"
DEFAULT_BASE_DIR_PATH="/home/pi/recordings"
BASE_DIR_PATH="/home/pi/data"
DEFAULT_BASE_DIR_PATH=/home/pi/recordings
BASE_DIR_PATH=/home/pi/data

View File

@ -1,7 +1,5 @@
#!/bin/sh
set -euo pipefail
# Copy the files to /home/pi
cd /home/pi
cp -R /boot/hydrophonitor .
@ -21,7 +19,7 @@ sh scripts/setup-pressure-depth.sh
# Setup cron job to start the recordings at boot
CRON_FILE=/etc/crontab
echo "@reboot root /home/pi/hydrophonitor/scripts/start-all.sh" >> $CRON_FILE
echo "@reboot root /home/pi/hydrophonitor/scripts/start-all.sh" | sudo tee -a $CRON_FILE
# Reboot
sudo reboot

View File

@ -10,7 +10,7 @@ parser.add_argument('-i', '--interval', help='Interval in seconds', required=Fal
args = parser.parse_args()
filename = args.output + time.strftime("%Y-%m-%dT%H-%M-%S") + "_GPS_data.csv"
filename = args.output + "/" + time.strftime("%Y-%m-%dT%H-%M-%S") + "_GPS_data.csv"
with open(filename, "w", 1) as f:
gpsd = gps(mode=WATCH_ENABLE|WATCH_NEWSTYLE)

View File

@ -1,5 +1,5 @@
#!/bin/sh
CONFIG_FILE=/boot/hydrophonitor/hydrophonitor-config.txt
CONFIG_FILE=/boot/hydrophonitor/configuration/hydrophonitor-config.txt
export $(grep -v '^#' $CONFIG_FILE | xargs -d '\n')

View File

@ -1,11 +1,12 @@
#!/bin/sh
# Get ID and number of the USB audio device
# Install packages
sudo apt-get update && sudo apt-get install -y libasound2-dev libjack-dev jackd2
# Get ID and number of the USB audio device
card_number=$(aplay -l | grep -i usb | grep -i audio | cut -d ' ' -f 2 | cut -d ':' -f 1)
# Change default audio device
sudo touch /etc/asound.conf
sudo cat << EOF | sudo tee -a /etc/asound.conf

View File

@ -1,13 +1,17 @@
#!/bin/sh
set -euo pipefail
# Export the configuration values
. /home/pi/hydrophonitor/scripts/export-config-values.sh
# Create output directory
OUTPUT_DIR=$BASE_DIR_PATH/$(date +"%Y-%m-%d_%H-%M-%S_output")
mkdir -p $OUTPUT_DIR
mkdir -p $OUTPUT_DIR/audio
(export OUTPUT_DIR=$OUTPUT_DIR; trap 'kill 0' SIGINT; ./scripts/start-gps.sh & ./scripts/start-audio.sh & ./scripts/start-pressure-depth.sh)
sleep 10
# (export OUTPUT_DIR=$OUTPUT_DIR; trap 'kill 0' SIGINT; /home/pi/hydrophonitor/scripts/scripts/start-gps.sh & /home/pi/hydrophonitor/scripts/start-audio.sh & /home/pi/hydrophonitor/scripts/start-pressure-depth.sh)
echo "(export OUTPUT_DIR=$OUTPUT_DIR; /home/pi/hydrophonitor/scripts/start-audio.sh & /home/pi/hydrophonitor/scripts/start-gps.sh)" >> $OUTPUT_DIR/log.txt 2>&1
(export OUTPUT_DIR=$OUTPUT_DIR; /home/pi/hydrophonitor/scripts/start-audio.sh & /home/pi/hydrophonitor/scripts/start-gps.sh) >> $OUTPUT_DIR/log.txt 2>&1

View File

@ -8,11 +8,13 @@ AUDIO_TARGET_EXECUTABLE="audio"
OPTIONS="rec \
--name audio_data \
--output $OUTPUT_DIR \
--output $OUTPUT_DIR/audio \
--batch-recording $BATCH_RECORD_LENGTH \
--sample-rate $SAMPLE_RATE \
--channels $CHANNELS \
--buffer-size 1024 \
alsa"
cd $AUDIO_TARGET_LOCATION && ./$AUDIO_TARGET_EXECUTABLE $OPTIONS
echo "cd $AUDIO_TARGET_LOCATION && ./$AUDIO_TARGET_EXECUTABLE $OPTIONS"
cd $AUDIO_TARGET_LOCATION && ./$AUDIO_TARGET_EXECUTABLE $OPTIONS

View File

@ -6,4 +6,6 @@
GPS_EXECUTABLE_LOCATION="/home/pi/hydrophonitor/gps-logger"
OPTIONS="--output $OUTPUT_DIR --interval $GPS_INTERVAL"
echo "cd $GPS_EXECUTABLE_LOCATION && python record-gps.py $OPTIONS"
cd $GPS_EXECUTABLE_LOCATION && python record-gps.py $OPTIONS