PiSupply / PiJuice

Resources for PiJuice HAT for Raspberry Pi - use your Pi Anywhere
https://www.pi-supply.com/product/pijuice-standard/
GNU General Public License v3.0
433 stars 102 forks source link

Modiffication of pijuice_sys.py: watchdog works during reboot process #1023

Open jmirek opened 8 months ago

jmirek commented 8 months ago

I use pijuice version 1.7. I have a situation where rpi hangs during restart. To avoid this situation, I used the pijuice watchdog option and modified /usr/bin/pijuice_sys.py:


change (line 326):

    if watchdogEn: _ConfigureWatchdog('DEACTIVATE')

    sysJobTargets = subprocess.check_output(["sudo", "systemctl", "list-jobs"]).decode('utf-8')
    reboot = True if re.search('reboot.target.*start', sysJobTargets) is not None else False                      # reboot.target exists
    swStop = True if re.search('(?:halt|shutdown).target.*start', sysJobTargets) is not None else False           # shutdown | halt exists
    causePowerOff = True if (swStop and not reboot) else False
    ret = pijuice.status.GetStatus()

into:

    #if watchdogEn: _ConfigureWatchdog('DEACTIVATE')

    sysJobTargets = subprocess.check_output(["sudo", "systemctl", "list-jobs"]).decode('utf-8')
    reboot = True if re.search('reboot.target.*start', sysJobTargets) is not None else False                      # reboot.target exists
    swStop = True if re.search('(?:halt|shutdown).target.*start', sysJobTargets) is not None else False           # shutdown | halt exists
    causePowerOff = True if (swStop and not reboot) else False

    if ( not reboot ):
        if watchdogEn: _ConfigureWatchdog('DEACTIVATE')

    ret = pijuice.status.GetStatus()**

After this modification watchdog is working during reboot, but not during shutdown. After modification restart pijuice service or reboot.

Could this modification be part of the new release?