From b2b465eb6a92ce0898ed3c032b14b0303f50a7b1 Mon Sep 17 00:00:00 2001 From: Manuel Date: Tue, 5 Sep 2023 15:14:34 +0200 Subject: [PATCH] improved reinstall and disable script --- CHANGELOG.md | 1 + etc/dbus-serialbattery/disable.sh | 14 +++++++++++--- etc/dbus-serialbattery/reinstall-local.sh | 19 +++++++++++++++---- etc/dbus-serialbattery/utils.py | 2 +- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfa909be..cb9ac501 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ * Changed: For BMS_TYPE now multiple BMS can be specified by @mr-manuel * Changed: Improved battery error handling on connection loss by @mr-manuel * Changed: Improved battery voltage handling in linear absorption mode by @ogurevich +* Changed: Improved driver disable script by @md-manuel * Changed: Improved driver reinstall when multiple Bluetooth BMS are enabled by @mr-manuel * Changed: Improved Jkbms_Ble driver by @seidler2547 & @mr-manuel * Changed: LLT/JBD - Fix cycle capacity with https://github.com/Louisvdw/dbus-serialbattery/pull/762 by @idstein diff --git a/etc/dbus-serialbattery/disable.sh b/etc/dbus-serialbattery/disable.sh index bd0c5d1c..13216cfe 100755 --- a/etc/dbus-serialbattery/disable.sh +++ b/etc/dbus-serialbattery/disable.sh @@ -8,6 +8,8 @@ bash /opt/victronenergy/swupdate-scripts/remount-rw.sh # remove driver from serial starter rm -f /data/conf/serial-starter.d/dbus-serialbattery.conf +# remove serial-starter.d if empty +rmdir /data/conf/serial-starter.d >/dev/null 2>&1 # kill serial starter, to reload changes pkill -f "/opt/victronenergy/serial-starter/serial-starter.sh" @@ -16,14 +18,20 @@ rm -rf /service/dbus-serialbattery.* rm -rf /service/dbus-blebattery.* # kill driver, if running -pkill -f "dbus-serialbattery" -pkill -f "dbus-blebattery" +# serial +pkill -f "supervise dbus-serialbattery.*" +pkill -f "multilog .* /var/log/dbus-serialbattery.*" +pkill -f "python .*/dbus-serialbattery.py /dev/tty.*" +# bluetooth +pkill -f "supervise dbus-blebattery.*" +pkill -f "multilog .* /var/log/dbus-blebattery.*" +pkill -f "python .*/dbus-serialbattery.py .*_Ble" # remove install script from rc.local sed -i "/bash \/data\/etc\/dbus-serialbattery\/reinstall-local.sh/d" /data/rc.local # remove cronjob -sed -i "/5 0,12 \* \* \* \/etc\/init.d\/bluetooth restart/d" /var/spool/cron/root +sed -i "/5 0,12 \* \* \* \/etc\/init.d\/bluetooth restart/d" /var/spool/cron/root >/dev/null 2>&1 ### needed for upgrading from older versions | start ### diff --git a/etc/dbus-serialbattery/reinstall-local.sh b/etc/dbus-serialbattery/reinstall-local.sh index 4a9cd98d..f1e98645 100755 --- a/etc/dbus-serialbattery/reinstall-local.sh +++ b/etc/dbus-serialbattery/reinstall-local.sh @@ -123,6 +123,8 @@ if [ ! -f "$filename" ]; then fi # kill driver, if running. It gets restarted by the service daemon +pkill -f "supervise dbus-serialbattery.*" +pkill -f "multilog .* /var/log/dbus-serialbattery.*" pkill -f "python .*/dbus-serialbattery.py /dev/tty.*" @@ -168,15 +170,21 @@ if [ "$length" -gt 0 ]; then echo "Found $length Bluetooth BMS in the config file!" echo + /etc/init.d/bluetooth stop + echo + # install required packages # TO DO: Check first if packages are already installed echo "Installing required packages to use Bluetooth connection..." opkg update opkg install python3-misc python3-pip - pip3 install bleak - # pip3 install bleak==0.20.2 + + echo + pip3 install bleak==0.20.2 # pip3 install bleak==0.21.0 + + echo pip3 install dbus-fast==1.87.0 # pip3 install dbus-fast==1.87.3 # pip3 install dbus-fast==1.87.4 @@ -184,6 +192,9 @@ if [ "$length" -gt 0 ]; then echo "done." echo + /etc/init.d/bluetooth start + echo + # function to install ble battery install_blebattery_service() { if [ -z "$1" ]; then @@ -253,12 +264,12 @@ if [ "$length" -gt 0 ]; then # grep -qxF "5 0,12 * * * /etc/init.d/bluetooth restart" /var/spool/cron/root || echo "5 0,12 * * * /etc/init.d/bluetooth restart" >> /var/spool/cron/root # remove cronjob - sed -i "/5 0,12 \* \* \* \/etc\/init.d\/bluetooth restart/d" /var/spool/cron/root + sed -i "/5 0,12 \* \* \* \/etc\/init.d\/bluetooth restart/d" /var/spool/cron/root >/dev/null 2>&1 else # remove cronjob - sed -i "/5 0,12 \* \* \* \/etc\/init.d\/bluetooth restart/d" /var/spool/cron/root + sed -i "/5 0,12 \* \* \* \/etc\/init.d\/bluetooth restart/d" /var/spool/cron/root >/dev/null 2>&1 echo echo "No Bluetooth battery configuration found in \"/data/etc/dbus-serialbattery/config.ini\"." diff --git a/etc/dbus-serialbattery/utils.py b/etc/dbus-serialbattery/utils.py index 8575c1a9..040c7643 100644 --- a/etc/dbus-serialbattery/utils.py +++ b/etc/dbus-serialbattery/utils.py @@ -38,7 +38,7 @@ def _get_list_from_config( # Constants -DRIVER_VERSION = "1.0.20230904dev" +DRIVER_VERSION = "1.0.20230905dev" zero_char = chr(48) degree_sign = "\N{DEGREE SIGN}"