Skip to content

Commit a96c831

Browse files
authored
Merge pull request #92 from jkuusk/dev
Dev
2 parents 1a2e1f1 + fc56d4f commit a96c831

File tree

12 files changed

+110
-31
lines changed

12 files changed

+110
-31
lines changed

hypernets/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2.2.0"
1+
__version__ = "2.3.0"
22

33
import sys
44
MIN_PYTHON = (3, 9)

hypernets/abstract/create_metadata.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ def parse_config_metadata(sequence_file, config_file="config_dynamic.ini",
4141
# copy user-defined metadata from config file
4242
str_metadata = "[Metadata]\n"
4343
for field in metadata_section.keys():
44-
str_metadata += f"{field} = {metadata_section[field]}\n"
44+
if field in ["hypernets_tools_version", "datetime", "hypstar_sn", "led_sn",
45+
"protocol_file_name", "latitude", "longitude", "offset_pan",
46+
"offset_tilt", "azimuth_switch"]:
47+
warning(f"metadata:{field} is auto-generated and should be removed "
48+
"from the [metadata] section of config_dynamic.ini")
49+
else:
50+
str_metadata += f"{field} = {metadata_section[field]}\n"
4551

4652
# populate auto-generated metadata
4753
str_metadata += f"hypernets_tools_version = {__version__}\n"

hypernets/geometry/spa_hypernets.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from datetime import datetime, timezone
33
import warnings
44

5-
from logging import info, debug
5+
from logging import info, debug, error
66

77

88
def spa_from_datetime(now=None):
@@ -41,7 +41,10 @@ def spa_from_datetime(now=None):
4141
def spa_from_gps():
4242
from hypernets.yocto.gps import get_gps
4343
latitude, longitude, now = get_gps()
44-
# TODO : test the gps trame
44+
45+
if (now == b'N/A'):
46+
raise Exception("No GPS fix")
47+
4548
now = datetime.strptime(now, '%Y/%m/%d %H:%M:%S')
4649
now.replace(tzinfo=timezone.utc) # GPS = utc
4750

@@ -59,9 +62,12 @@ def spa_from_gps():
5962
if __name__ == '__main__':
6063
print("From datetime + fixed coords in config_dynamic.ini : ")
6164
azimuth_sun, zenith_sun = spa_from_datetime()
62-
print(f"Azimuth Sun : {azimuth_sun} ; Zenith Sun : {zenith_sun}")
63-
print("From GPS")
64-
azimuth_sun, zenith_sun = spa_from_gps()
65-
print(f"Azimuth Sun : {azimuth_sun} ; Zenith Sun : {zenith_sun}")
65+
print(f"Azimuth Sun : {azimuth_sun:.3f} ; Zenith Sun : {zenith_sun:.3f}")
6666

67+
try:
68+
print("From GPS")
69+
azimuth_sun, zenith_sun = spa_from_gps()
70+
print(f"Azimuth Sun : {azimuth_sun:.3f} ; Zenith Sun : {zenith_sun:.3f}")
71+
except Exception as e:
72+
error(f"{e}")
6773

install/01_dependencies.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ elif [ "$ID" == "manjaro" ]; then
7979
echo -e "\n----------------------------------------------------\n"
8080
echo -e "WARNING!!!!\n"
8181
echo "Manjaro has been upgraded from version '${old_os_ver:-}' to '${DISTRIB_RELEASE:-}'"
82-
echo -e "You should re-install libhypstar and rain sensor\n"
82+
echo -e "You should re-install libhypstar and rain sensor and re-configure ports\n"
8383
fi
8484
fi
8585
fi

install/03_update_libhypstar.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ sudo -u $user git submodule update
2323

2424
# Update and Install
2525
cd hypernets/hypstar/libhypstar/
26-
sudo -u $user git checkout vm_dev
26+
sudo -u $user git checkout main
2727
sudo -u $user git pull
2828
sudo -u $user make clean lib
2929
make install

install/bash_aliases

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,7 @@ schedule() (
677677
echo "All inactive is equivalent to all set for a single field"
678678
echo "All inactive for all fields disables the schedule"
679679

680-
for n_sched in 1 2;
681-
do
680+
for n_sched in 1 2; do
682681
echo "----------------------------------------------------------"
683682
echo " ${HL}Schedule $n_sched${RESET_HL}"
684683
echo -e -n "Months:\t\t"
@@ -702,7 +701,11 @@ schedule() (
702701

703702
echo -e -n "Weekdays:\t"
704703
YWakeUpSchedule -f '[result]' -r 127.0.0.1 "$yoctowifibrd".wakeUpSchedule"$n_sched" get_weekDays
705-
704+
first_h=""
705+
first_m=""
706+
last_h=""
707+
last_m=""
708+
706709
hours=$(YWakeUpSchedule -f '[result]' -r 127.0.0.1 "$yoctowifibrd".wakeUpSchedule"$n_sched" get_hours)
707710
if [[ "$hours" =~ ^\[\.*\]$ ]]; then
708711
echo -e "Hours:\t\t$hours"
@@ -711,6 +714,12 @@ schedule() (
711714
for ((i = 0; i < 24; i++)); do
712715
if [[ "${hours:i+1:1}" != "." ]]; then
713716
echo -n "$i "
717+
718+
## store for SZA calculation
719+
if [[ "$first_h" == "" ]]; then
720+
first_h="$i"
721+
fi
722+
last_h="$i"
714723
else
715724
echo -n ". "
716725
fi
@@ -726,13 +735,47 @@ schedule() (
726735
for ((i = (($length - 1)), j=0; i >= 0; i--, j++)); do
727736
if [[ "${minutes_bin:i:1}" == "1" ]]; then
728737
echo -n "$j,"
738+
739+
## store for SZA calculation
740+
if [[ "$first_m" == "" ]]; then
741+
first_m="$j"
742+
fi
743+
last_m="$j"
729744
fi
730745
done
731746
if [[ $minutes_dec != "0" ]]; then
732747
tput cub 1
748+
else
749+
first_m=0
750+
last_m=59
733751
fi
734752
echo "]"
735-
done
753+
754+
## calculate SZA
755+
if [[ "$first_h" != "" ]]; then
756+
tz_offset_h=$(printf "%+d" $(("$yocto_offset" / 3600)))
757+
tz_offset_m=$(printf "%+d" $(( ("$yocto_offset" - 3600 * "$tz_offset_h" ) / 60)))
758+
first_timestr=$(printf "%sT%02d:%02d%+03d:%02d" $(date '+%Y-%m-%d') "$first_h" "$first_m" "$tz_offset_h" "$tz_offset_m")
759+
last_timestr=$(printf "%sT%02d:%02d%+03d:%02d" $(date '+%Y-%m-%d') "$last_h" "$last_m" "$tz_offset_h" "$tz_offset_m")
760+
761+
python_script=$(cat << EOF
762+
import datetime
763+
from hypernets.geometry.spa_hypernets import spa_from_datetime
764+
765+
timestamp = datetime.datetime.fromisoformat("$first_timestr")
766+
first_azimuth_sun, first_zenith_sun = spa_from_datetime(timestamp)
767+
timestamp = datetime.datetime.fromisoformat("$last_timestr")
768+
last_azimuth_sun, last_zenith_sun = spa_from_datetime(timestamp)
769+
770+
first_el_sun = 90 - first_zenith_sun
771+
last_el_sun = 90 - last_zenith_sun
772+
print(f"Sun elevation at the beginning of the first and last sequence as of today: {first_el_sun:.1f}, {last_el_sun:.1f}")
773+
EOF
774+
)
775+
776+
python -c "$python_script"
777+
fi # if [[ "$first_h" == "" ]]
778+
done # n_sched in 1 2
736779

737780
echo "----------------------------------------------------------"
738781
echo -n "Rugged PC date & time: "
@@ -1498,8 +1541,8 @@ webpic() (
14981541
set +e
14991542
set pipefail
15001543
export AV_LOG_FORCE_COLOR=1
1501-
echo "utils/webcam_get_image.sh -v -c $webcam_credent -i $webcam_ip -d OTHER/WEBCAM_${cam^^}/$YMFolder 2>&1 | tee /dev/fd/2"
1502-
cap_out=$(utils/webcam_get_image.sh -v -c "$webcam_credent" -i "$webcam_ip" -d "OTHER/WEBCAM_${cam^^}/$YMFolder" 2>&1 | tee /dev/fd/2)
1544+
echo "utils/webcam_get_image.sh -w -v -c $webcam_credent -i $webcam_ip -d OTHER/WEBCAM_${cam^^}/$YMFolder 2>&1 | tee /dev/fd/2"
1545+
cap_out=$(utils/webcam_get_image.sh -w -v -c "$webcam_credent" -i "$webcam_ip" -d "OTHER/WEBCAM_${cam^^}/$YMFolder" 2>&1 | tee /dev/fd/2)
15031546
cap_retcode=$?
15041547

15051548
if [[ "$cap_retcode" -ne 0 ]]; then

release_notes.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1+
Version 2.3.0: (2024-10-23)
2+
- Log also systemd-timesyncd messages in hello.log
3+
4+
Version 2.2.2: (2024-10-07)
5+
- Recommend re-configuring ports in case of Manjaro release update
6+
- schedule command line shortcut shows Sun elevation at the beginning of the
7+
first and last scheduled sequence as of the current date
8+
- Check connection to network server instead of google in access.service
9+
- Probe rtsp port of webcam instead of pinging when waiting for
10+
the webcam to boot
11+
12+
Version 2.2.1: (2024-09-03)
13+
- Ignore auto-generated metadata fields in config_dynamic.ini
14+
- Warn if keep_pc = on and Yocto WDT is configured
15+
- Reduce webcam timeout
16+
117
Version 2.2.0: (2024-09-03)
218
- Park to nadir and shut down gracefully 2 minutes before Yocto
3-
Watchdog Timer hard power off
19+
Watchdog Timer hard power off
420

521
Version 2.1.0: (2024-08-28)
622
- Move network traffic from sequecnce.log to hello.log

utils/hello_server.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ remove_old_backups_from_archive() {
183183
}
184184

185185
make_log $logNameBase sequence
186-
make_log $logNameBase hello
186+
make_log $logNameBase hello systemd-timesyncd
187187
make_log $logNameBase access ssh sshd
188188
make_log $logNameBase webcam
189189
disk_usage

utils/reverse_ssh.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ set +e
4545
echo "[INFO] Waiting for network..."
4646
ipServer_ip=$(cut -d "@" -f2 <<< $ipServer)
4747
while true ; do
48-
## make a few different attempts to satisfy all distros
49-
if nc -zw1 google.com 443 > /dev/null 2>&1 || \
50-
ping -q -c 1 -W 1 google.com > /dev/null 2>&1 || \
51-
wget -q --spider http://google.com > /dev/null 2>&1
48+
if nc -zw1 "$ipServer_ip" "$sshPort" >/dev/null 2>&1
5249
then
5350
echo "[INFO] got response from the network server"
5451
break

0 commit comments

Comments
 (0)