From af3f83275853564973889c4d353cf58151de5056 Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 29 Jan 2021 14:21:03 +0100 Subject: [PATCH] fixed buzzer thread fixed logging fixed postinstall.sh --- build_deb.sh | 2 +- compLib/VisionDaemon.py | 15 ++++++++++++++- compLib/__init__.py | 2 +- postinstall.sh | 8 ++++++++ setup.py | 2 +- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/build_deb.sh b/build_deb.sh index 4d49971..e0ba84a 100644 --- a/build_deb.sh +++ b/build_deb.sh @@ -32,7 +32,7 @@ fpm -s python --python-bin python3 --python-pip pip3 --python-package-name-prefi -d "python-pigpio" \ -d "python3-pigpio" \ -d "python3-numpy" \ - -v 0.0.4-2 -t deb setup.py + -v 0.0.4-6 -t deb setup.py # --deb-changelog changelog \ # --deb-upstream-changelog changelog \ diff --git a/compLib/VisionDaemon.py b/compLib/VisionDaemon.py index 36a2cde..c9b8d97 100644 --- a/compLib/VisionDaemon.py +++ b/compLib/VisionDaemon.py @@ -1,4 +1,5 @@ import os +import threading import time import systemd.daemon @@ -15,7 +16,11 @@ __run = """raspivid -t 0 -b 5000000 -w 1280 -h 720 -fps 30 -n -o - | gst-launch- def check_battery(): while True: time.sleep(2) - battery = Battery.percent() + battery = 0 + try: + battery = Battery.percent() + except Exception as e: + logstash_logger.error(f"could not check battery -> {str(e)}") if battery <= 15: logstash_logger.warning(f"LOW BATTERY DETECTED: '{battery}'") Buzzer.set(True) @@ -30,6 +35,14 @@ if __name__ == '__main__': logstash_logger.warning("Warning, old systemd version detected") systemd.daemon.notify('READY=1') + logstash_logger.info("starting battery checker") + try: + battery_checker = threading.Thread(target=check_battery) + battery_checker.start() + logstash_logger.info("starting battery checker - DONE") + except Exception as e: + logstash_logger.error(f"could not start battery checker -> {str(e)}") + logstash_logger.info("starting gstreamer background process") os.system(__run) logstash_logger.error("gstreamer stopped...") diff --git a/compLib/__init__.py b/compLib/__init__.py index a5afb15..f0b933e 100644 --- a/compLib/__init__.py +++ b/compLib/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.0.4" +__version__ = "0.0.4-6" import compLib.LogstashLogging import logging diff --git a/postinstall.sh b/postinstall.sh index e7547c7..2122420 100644 --- a/postinstall.sh +++ b/postinstall.sh @@ -13,6 +13,7 @@ install_package "smbus" install_package "requests" install_package "flask" install_package "python-logstash-async" +install_package "RPi.GPIO" echo "Setting up opencv4" pkg-config --modversion opencv4 @@ -41,3 +42,10 @@ echo "Starting pigpiod daemon" sudo systemctl start pigpiod sudo systemctl enable pigpiod + +echo "Enabling camera via raspi-conf" +raspi-config nonint do_camera 1 + +RED='\033[0;31m' +NC='\033[0m' +echo -e "${RED}IF THIS IS THE FIRST INSTALL REBOOT YOUR PIE NOW!${NC}" diff --git a/setup.py b/setup.py index 2c53186..896299d 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ else: setuptools.setup( name="complib", - version="0.0.2", + version="0.0.4-6", author="F-WuTs", author_email="--", description="",