From fae1f27c7a5ca7cec229f7698e302bfc26d8b97e Mon Sep 17 00:00:00 2001 From: kwindrem <58538395+kwindrem@users.noreply.github.com> Date: Tue, 28 Sep 2021 11:35:19 -0700 Subject: [PATCH] Add Shutdown command --- .DS_Store | Bin 6148 -> 10244 bytes FileSets/.DS_Store | Bin 6148 -> 8196 bytes FileSets/fileList | 1 + FileSets/gpio_list | 9 ++ FileSets/v2.40/PageSettingsGeneral.qml | 135 ++++++++++++++++++ FileSets/v2.40/PageSettingsGeneral.qml.orig | 109 +++++++++++++++ FileSets/v2.60/.DS_Store | Bin 0 -> 6148 bytes FileSets/v2.60/PageSettingsGeneral.qml | 143 ++++++++++++++++++++ FileSets/v2.60/PageSettingsGeneral.qml.orig | 117 ++++++++++++++++ FileSets/v2.71/.DS_Store | Bin 0 -> 6148 bytes FileSets/v2.71/PageSettingsGeneral.qml | 143 ++++++++++++++++++++ FileSets/v2.71/PageSettingsGeneral.qml.orig | 117 ++++++++++++++++ GracefulShutdown.sh | 31 +++++ ReadMe | 12 +- service/.DS_Store | Bin 0 -> 6148 bytes service/log/run | 3 + service/run | 4 + setup | 31 ++++- timeStamp | 2 +- version | 2 +- 20 files changed, 852 insertions(+), 7 deletions(-) create mode 100644 FileSets/v2.40/PageSettingsGeneral.qml create mode 100644 FileSets/v2.40/PageSettingsGeneral.qml.orig create mode 100644 FileSets/v2.60/.DS_Store create mode 100644 FileSets/v2.60/PageSettingsGeneral.qml create mode 100644 FileSets/v2.60/PageSettingsGeneral.qml.orig create mode 100644 FileSets/v2.71/.DS_Store create mode 100644 FileSets/v2.71/PageSettingsGeneral.qml create mode 100644 FileSets/v2.71/PageSettingsGeneral.qml.orig create mode 100755 GracefulShutdown.sh create mode 100644 service/.DS_Store create mode 100755 service/log/run create mode 100755 service/run diff --git a/.DS_Store b/.DS_Store index 43760d99a778cdf6b09e7deb634a33d7debf4575..296730cbe0174d574cbfefe63848f4305edb221b 100644 GIT binary patch literal 10244 zcmeHMdu$X%7@u!jVAmBoSAoJ(;G`n223tTV$m7}`k5aUiYw3eW*}GlZjeEQ2?cN=w z6btb$QUCK1h|xqek|=)(Mxs$;G>VBDa^fQ~5=s2a7$1p`Xw+|Z_L^R=VEDrX<4!X3 z&CK_GGqb<_eLFXEgb--TX!V4I2_Yh8Ch5&sOputK<&q@$Jt35U{>1FBk0tD6s>Cwr z2oMMm2oMMm2oMMmxKR+mJ)0#_<}xS)1OfyC1V#~H--j?}CL_Ka;nMqbVBsABP?lr2 zm#|J*1!dTm5nqmQi5g76T~TsZ@Q)b4-LXIH+eLgi!XciD7n$6VEv*e~t_Blxa9_UEQZ3l$B4KJVg{mS)3~FjSbkjn5()O zr%6rkX03MB9fuP+Lq38PO^k&;~Rm0NLp0lCpXtJlvurxc@WM?eR@y3a9 zg(OL$)JJCz4K*~ZsSU4Kv0}J3JhXOoLv6UeZtcq9VM(l7SihlVe{%59(Ba`DClCcp z;D4A%1#gd*C$U!Yq?(g35+(8kF&bEwL~1*pC#KqcKI%TtxkU7cOs zJ$;mB9DS#5s;-gMqpGVreYCS%QI$nWevxOn|hDxBy>wNtp3iNp}7OS_KiVrmF156kSElUxNBX#taO@cTsNsE@p=zOJNzTf(SH16SP7*?1UI}z+Q-h209!78#0iCgD?ok;30Sz9)U;U33vvcg;Vex zoPpQj4R{mYf(wv`Pv8=K1()G#xB}n7FYqh;Cdk5cVTLeMSRyPHRtoEdMqxW&yHE(g zUfwR0!VavJ#+Z}!KQ+Q*6UR^Www7(%Ti4vM@$>mK7BRO>pE0v4%)+Q)L(?eZI7JJr z9Lsf&;6-8K5!|D}IA-QCuI5zFmFE{ClE>kgxWvfN4~mT5bPBg#Am1ipWY9^xxkz3j zVocDS%d>jxu}JMmZu=!lGW{ zBSovXh!{Ck{6|V(lhE&zi{vvT^tVXpKcNgnsDdyohUL%z8(|YtxEVIXJ0t5mC0t5mC z0tBuHfii9!X7~S_um1o4^$Z!<1_%TQ{KpW0@@OpDgo`empvSMD-L;1?@5js%vm4>k zbHRd{uzv449vkeA(7R&5KL2vT(?@)}5iUJ<^z+|IYx&49@@lwODZe|6iW} F{|3cZ5{v)< delta 242 zcmZn(XfcprU|?W$DortDU=RQ@Ie-{MGjUE#6q~50$jGrVU^gQp$7CJ>sW_gKKp7SW zJ%)6KOoo!&d>5Cboctt^uEzds*`M`?9Z}^|@X8lt7zQWj=N16<0PRa)n7m$4bn*g0 z9%hD(5|fvRE3q&r{;Z#TN?ZlP_$02vD6lc{4a;J74h}(Pur3AxZXoRna_+{&@640= ZRUAS7VPFI~69||f9s-MPj^~-f3;+^3GU5OL diff --git a/FileSets/.DS_Store b/FileSets/.DS_Store index e1f69b4826d820b8311105567cef80797ad53dac..ed58f526908d28524f19537f35f42042c4872ad2 100644 GIT binary patch literal 8196 zcmeHM&ubGw6n@jDx}k_U2ra$17X=~6Zer5(AgnQhB1mCH4^`T1H#C9GZpe>@8dJ7^ zhu%E(Pw?zXdKU302>u(s`H{M_*(mfN1>eBTx0(6gyl+36*}e?`u=>ci0oDP)z|OI- zibF=@>%7mkB{g#skzqW5<&6hDFNnN3E=`aFUfDh67WXnW|8j$c}NQpaXLx(nt=F1M?2>+Isq~dA*=B7+Tg> zwzQmExpLJoj8)^B@!D-iV|Umbjt2E+e}{kCZVua?x_%x-!TEL5d(ml)cMCTjM&Yp8 z30r*;-0@pTdG)dr`q8)^jY5AQ_HpGxKA$)8yM>L(#4cCMMYCKgO^fDat6D3XwzXBB zPV>gvE&KkHz3$PQ$=m7iJ9%GBoegk3b)WC`oAd|!frm0VJ#p{Bf$i=`-JT47c3WTV zMvaDgvw=rVe0p~B=|P&||Ao7G~dZdj1PLXdnkJ?7*^& zT<7)wqs8z4FT6hmk^|(x<#&MP8g8SGI%oesrzP`R+r++yoj1;lC5jLnL^+Nq%5lW= d9}Mx@L@JMQ6vh&91{=Ky5H`?24*XLGegS8(1lRxo delta 216 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{MGjUEV6q~50D8dht2a6e`6es5-<>%)xZY*5E z$jCqWqkyrJK`~ICm7$Emh(V9Rgux&;-^C>= User.AccessInstaller && ++repeatCount > 60) { + if (accessLevelSelect.value !== User.AccessSuperUser) + accessLevelSelect.item.setValue(User.AccessSuperUser) + repeatCount = 0 + } + } + } + + MbEditBox { + show: user.accessLevel >= User.AccessSuperUser + description: "Set root password" + onEditDone: { + if (newValue.length < 6) { + toast.createToast("Please enter at least 6 characters") + } else { + toast.createToast(vePlatform.setRootPassword(newValue)) + item.value = "" + } + } + } + + MbSwitch { + name: qsTr("SSH on LAN") + show: user.accessLevel >= User.AccessSuperUser + bind: "com.victronenergy.settings/Settings/System/SSHLocal" + } + + MbSwitch { + id: remoteSupportOnOff + name: qsTr("Remote support") + bind: "com.victronenergy.settings/Settings/System/RemoteSupport" + } + + MbItemValue { + description: qsTr("Remote support tunnel") + item.value: remotePort.item.valid && remotePort.item.value !== 0 ? qsTr("Online") : qsTr("Offline") + show: remoteSupportOnOff.item.value + } + + MbItemValue { + id: remotePort + description: qsTr("Remote support port") + item.bind: "com.victronenergy.settings/Settings/System/RemoteSupportPort" + show: remoteSupportOnOff.item.value + } + + MbOK { + id: reboot + description: qsTr("Reboot?") + writeAccessLevel: User.AccessUser + onClicked: { + toast.createToast(qsTr("Rebooting..."), 10000, "icon-restart-active") + vePlatform.reboot() + } + } +//////// add for Shutdown command + // shutdown uses a psudo relay output connected to a psudo digital input + // shutdownItem is the relay state in system + // shutdownItem2 is the relay innitial state in settings + // the latter must not remain set through the shutdown or the system + // will shutdown immediately on startup!!! + MbOK { + id: shutdown + description: qsTr("Shutdown?") + writeAccessLevel: User.AccessUser + onClicked: + { + toast.createToast(qsTr("Shutting down..."), 10000, "icon-restart-active") + if (shutdownItem.valid) + shutdownItem.setValue (1) + if (shutdownItem2.valid) + shutdownItem2.setValue (0) + } + } + + MbSwitch { + property VBusItem hasBuzzer: VBusItem {bind: "com.victronenergy.system/Buzzer/State"} + name: qsTr("Audible alarm") + bind: Utils.path(bindPrefix, "/Settings/Alarm/Audible") + show: hasBuzzer.valid + } + + MbItemOptions { + id: demoOnOff + description: qsTr("Demo mode") + bind: Utils.path(bindPrefix, "/Settings/Gui/DemoMode") + possibleValues: [ + MbOption { description: qsTr("Disabled"); value: 0 }, + MbOption { description: qsTr("ESS demo"); value: 1 }, + MbOption { description: qsTr("Boat/Motorhome demo 1"); value: 2 }, + MbOption { description: qsTr("Boat/Motorhome demo 2"); value: 3 } + ] + } + + MbItemText { + text: qsTr("Starting demo mode will change some settings and the user interface will be unresponsive for a moment.") + wrapMode: Text.WordWrap + } + } +} diff --git a/FileSets/v2.40/PageSettingsGeneral.qml.orig b/FileSets/v2.40/PageSettingsGeneral.qml.orig new file mode 100644 index 0000000..7f692e1 --- /dev/null +++ b/FileSets/v2.40/PageSettingsGeneral.qml.orig @@ -0,0 +1,109 @@ +import QtQuick 1.1 +import com.victron.velib 1.0 +import "utils.js" as Utils + +MbPage +{ + id: root + property string bindPrefix: "com.victronenergy.settings" + + model: VisualItemModel { + MbItemOptions { + id: accessLevelSelect + description: qsTr("Access level") + bind: Utils.path(bindPrefix, "/Settings/System/AccessLevel") + magicKeys: true + writeAccessLevel: User.AccessUser + possibleValues: [ + MbOption { description: qsTr("User"); value: User.AccessUser; password: "ZZZ" }, + MbOption { description: qsTr("User & Installer"); value: User.AccessInstaller; password: "ZZZ" }, + MbOption { description: qsTr("Superuser"); value: User.AccessSuperUser; readonly: true }, + MbOption { description: qsTr("Service"); value: User.AccessService; readonly: true } + ] + + // change to super user mode if the right button is pressed for a while + property int repeatCount + onFocusChanged: repeatCount = 0 + + function open() { + if (user.accessLevel >= User.AccessInstaller && ++repeatCount > 60) { + if (accessLevelSelect.value !== User.AccessSuperUser) + accessLevelSelect.item.setValue(User.AccessSuperUser) + repeatCount = 0 + } + } + } + + MbEditBox { + show: user.accessLevel >= User.AccessSuperUser + description: "Set root password" + onEditDone: { + if (newValue.length < 6) { + toast.createToast("Please enter at least 6 characters") + } else { + toast.createToast(vePlatform.setRootPassword(newValue)) + item.value = "" + } + } + } + + MbSwitch { + name: qsTr("SSH on LAN") + show: user.accessLevel >= User.AccessSuperUser + bind: "com.victronenergy.settings/Settings/System/SSHLocal" + } + + MbSwitch { + id: remoteSupportOnOff + name: qsTr("Remote support") + bind: "com.victronenergy.settings/Settings/System/RemoteSupport" + } + + MbItemValue { + description: qsTr("Remote support tunnel") + item.value: remotePort.item.valid && remotePort.item.value !== 0 ? qsTr("Online") : qsTr("Offline") + show: remoteSupportOnOff.item.value + } + + MbItemValue { + id: remotePort + description: qsTr("Remote support port") + item.bind: "com.victronenergy.settings/Settings/System/RemoteSupportPort" + show: remoteSupportOnOff.item.value + } + + MbOK { + id: reboot + description: qsTr("Reboot?") + writeAccessLevel: User.AccessUser + onClicked: { + toast.createToast(qsTr("Rebooting..."), 10000, "icon-restart-active") + vePlatform.reboot() + } + } + + MbSwitch { + property VBusItem hasBuzzer: VBusItem {bind: "com.victronenergy.system/Buzzer/State"} + name: qsTr("Audible alarm") + bind: Utils.path(bindPrefix, "/Settings/Alarm/Audible") + show: hasBuzzer.valid + } + + MbItemOptions { + id: demoOnOff + description: qsTr("Demo mode") + bind: Utils.path(bindPrefix, "/Settings/Gui/DemoMode") + possibleValues: [ + MbOption { description: qsTr("Disabled"); value: 0 }, + MbOption { description: qsTr("ESS demo"); value: 1 }, + MbOption { description: qsTr("Boat/Motorhome demo 1"); value: 2 }, + MbOption { description: qsTr("Boat/Motorhome demo 2"); value: 3 } + ] + } + + MbItemText { + text: qsTr("Starting demo mode will change some settings and the user interface will be unresponsive for a moment.") + wrapMode: Text.WordWrap + } + } +} diff --git a/FileSets/v2.60/.DS_Store b/FileSets/v2.60/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0= User.AccessInstaller) accessLevelSelect.item.setValue(User.AccessSuperUser) + } + + // change to super user mode if the right button is pressed for a while + property int repeatCount + onFocusChanged: repeatCount = 0 + + function open() { + if (user.accessLevel >= User.AccessInstaller && ++repeatCount > 60) { + if (accessLevelSelect.value !== User.AccessSuperUser) + accessLevelSelect.item.setValue(User.AccessSuperUser) + repeatCount = 0 + } + } + } + + MbEditBox { + show: user.accessLevel >= User.AccessSuperUser + description: "Set root password" + onEditDone: { + if (newValue.length < 6) { + toast.createToast("Please enter at least 6 characters") + } else { + toast.createToast(vePlatform.setRootPassword(newValue)) + item.value = "" + } + } + } + + MbSwitch { + name: qsTr("SSH on LAN") + show: user.accessLevel >= User.AccessSuperUser + bind: "com.victronenergy.settings/Settings/System/SSHLocal" + } + + MbSwitch { + id: remoteSupportOnOff + name: qsTr("Remote support") + bind: "com.victronenergy.settings/Settings/System/RemoteSupport" + } + + MbItemValue { + description: qsTr("Remote support tunnel") + item.value: remotePort.item.valid && remotePort.item.value !== 0 ? qsTr("Online") : qsTr("Offline") + show: remoteSupportOnOff.item.value + } + + MbItemValue { + id: remotePort + description: qsTr("Remote support IP and port") + item.bind: "com.victronenergy.settings/Settings/System/RemoteSupportIpAndPort" + show: remoteSupportOnOff.item.value + } + + MbOK { + id: reboot + description: qsTr("Reboot?") + writeAccessLevel: User.AccessUser + onClicked: { + toast.createToast(qsTr("Rebooting..."), 10000, "icon-restart-active") + vePlatform.reboot() + } + } +//////// add for Shutdown command + // shutdown uses a psudo relay output connected to a psudo digital input + // shutdownItem is the relay state in system + // shutdownItem2 is the relay innitial state in settings + // the latter must not remain set through the shutdown or the system + // will shutdown immediately on startup!!! + MbOK { + id: shutdown + description: qsTr("Shutdown?") + writeAccessLevel: User.AccessUser + onClicked: + { + toast.createToast(qsTr("Shutting down..."), 10000, "icon-restart-active") + if (shutdownItem.valid) + shutdownItem.setValue (1) + if (shutdownItem2.valid) + shutdownItem2.setValue (0) + } + } + + MbSwitch { + property VBusItem hasBuzzer: VBusItem {bind: "com.victronenergy.system/Buzzer/State"} + name: qsTr("Audible alarm") + bind: Utils.path(bindPrefix, "/Settings/Alarm/Audible") + show: hasBuzzer.valid + } + + MbItemOptions { + id: demoOnOff + description: qsTr("Demo mode") + bind: Utils.path(bindPrefix, "/Settings/Gui/DemoMode") + possibleValues: [ + MbOption { description: qsTr("Disabled"); value: 0 }, + MbOption { description: qsTr("ESS demo"); value: 1 }, + MbOption { description: qsTr("Boat/Motorhome demo 1"); value: 2 }, + MbOption { description: qsTr("Boat/Motorhome demo 2"); value: 3 } + ] + } + + MbItemText { + text: qsTr("Starting demo mode will change some settings and the user interface will be unresponsive for a moment.") + wrapMode: Text.WordWrap + } + } +} diff --git a/FileSets/v2.60/PageSettingsGeneral.qml.orig b/FileSets/v2.60/PageSettingsGeneral.qml.orig new file mode 100644 index 0000000..21a9c82 --- /dev/null +++ b/FileSets/v2.60/PageSettingsGeneral.qml.orig @@ -0,0 +1,117 @@ +import QtQuick 1.1 +import com.victron.velib 1.0 +import "utils.js" as Utils + +MbPage +{ + id: root + property string bindPrefix: "com.victronenergy.settings" + + model: VisualItemModel { + MbItemOptions { + id: accessLevelSelect + description: qsTr("Access level") + bind: Utils.path(bindPrefix, "/Settings/System/AccessLevel") + magicKeys: true + writeAccessLevel: User.AccessUser + possibleValues: [ + MbOption { description: qsTr("User"); value: User.AccessUser; password: "ZZZ" }, + MbOption { description: qsTr("User & Installer"); value: User.AccessInstaller; password: "ZZZ" }, + MbOption { description: qsTr("Superuser"); value: User.AccessSuperUser; readonly: true }, + MbOption { description: qsTr("Service"); value: User.AccessService; readonly: true } + ] + + // touch version to get super user + property bool pulledDown: listview.contentY < -60 + Timer { + running: accessLevelSelect.pulledDown + interval: 5000 + onTriggered: if (user.accessLevel >= User.AccessInstaller) accessLevelSelect.item.setValue(User.AccessSuperUser) + } + + // change to super user mode if the right button is pressed for a while + property int repeatCount + onFocusChanged: repeatCount = 0 + + function open() { + if (user.accessLevel >= User.AccessInstaller && ++repeatCount > 60) { + if (accessLevelSelect.value !== User.AccessSuperUser) + accessLevelSelect.item.setValue(User.AccessSuperUser) + repeatCount = 0 + } + } + } + + MbEditBox { + show: user.accessLevel >= User.AccessSuperUser + description: "Set root password" + onEditDone: { + if (newValue.length < 6) { + toast.createToast("Please enter at least 6 characters") + } else { + toast.createToast(vePlatform.setRootPassword(newValue)) + item.value = "" + } + } + } + + MbSwitch { + name: qsTr("SSH on LAN") + show: user.accessLevel >= User.AccessSuperUser + bind: "com.victronenergy.settings/Settings/System/SSHLocal" + } + + MbSwitch { + id: remoteSupportOnOff + name: qsTr("Remote support") + bind: "com.victronenergy.settings/Settings/System/RemoteSupport" + } + + MbItemValue { + description: qsTr("Remote support tunnel") + item.value: remotePort.item.valid && remotePort.item.value !== 0 ? qsTr("Online") : qsTr("Offline") + show: remoteSupportOnOff.item.value + } + + MbItemValue { + id: remotePort + description: qsTr("Remote support IP and port") + item.bind: "com.victronenergy.settings/Settings/System/RemoteSupportIpAndPort" + show: remoteSupportOnOff.item.value + } + + MbOK { + id: reboot + description: qsTr("Reboot?") + writeAccessLevel: User.AccessUser + onClicked: { + toast.createToast(qsTr("Rebooting..."), 10000, "icon-restart-active") + vePlatform.reboot() + } + } + + MbSwitch { + property VBusItem hasBuzzer: VBusItem {bind: "com.victronenergy.system/Buzzer/State"} + name: qsTr("Audible alarm") + bind: Utils.path(bindPrefix, "/Settings/Alarm/Audible") + show: hasBuzzer.valid + } + + MbItemOptions { + id: demoOnOff + description: qsTr("Demo mode") + bind: Utils.path(bindPrefix, "/Settings/Gui/DemoMode") + possibleValues: [ + MbOption { description: qsTr("Disabled"); value: 0 }, + MbOption { description: qsTr("ESS demo"); value: 1 }, + MbOption { description: qsTr("Boat/Motorhome demo 1"); value: 2 }, + MbOption { description: qsTr("Boat/Motorhome demo 2"); value: 3 } + ] + } + + MbItemText { + text: qsTr("Starting demo mode will change some settings and the user interface will be unresponsive for a moment.") + wrapMode: Text.WordWrap + } + } +} diff --git a/FileSets/v2.71/.DS_Store b/FileSets/v2.71/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0= User.AccessInstaller) accessLevelSelect.item.setValue(User.AccessSuperUser) + } + + // change to super user mode if the right button is pressed for a while + property int repeatCount + onFocusChanged: repeatCount = 0 + + function open() { + if (user.accessLevel >= User.AccessInstaller && ++repeatCount > 60) { + if (accessLevelSelect.value !== User.AccessSuperUser) + accessLevelSelect.item.setValue(User.AccessSuperUser) + repeatCount = 0 + } + } + } + + MbEditBox { + description: "Set root password" + showAccessLevel: User.AccessSuperUser + onEditDone: { + if (newValue.length < 6) { + toast.createToast("Please enter at least 6 characters") + } else { + toast.createToast(vePlatform.setRootPassword(newValue)) + item.value = "" + } + } + } + + MbSwitch { + name: qsTr("SSH on LAN") + showAccessLevel: User.AccessSuperUser + bind: "com.victronenergy.settings/Settings/System/SSHLocal" + } + + MbSwitch { + id: remoteSupportOnOff + name: qsTr("Remote support") + bind: "com.victronenergy.settings/Settings/System/RemoteSupport" + } + + MbItemValue { + description: qsTr("Remote support tunnel") + item.value: remotePort.item.valid && remotePort.item.value !== 0 ? qsTr("Online") : qsTr("Offline") + show: remoteSupportOnOff.item.value + } + + MbItemValue { + id: remotePort + description: qsTr("Remote support IP and port") + item.bind: "com.victronenergy.settings/Settings/System/RemoteSupportIpAndPort" + show: remoteSupportOnOff.item.value + } + + MbOK { + id: reboot + description: qsTr("Reboot?") + writeAccessLevel: User.AccessUser + onClicked: { + toast.createToast(qsTr("Rebooting..."), 10000, "icon-restart-active") + vePlatform.reboot() + } + } +//////// add for Shutdown command + // shutdown uses a psudo relay output connected to a psudo digital input + // shutdownItem is the relay state in system + // shutdownItem2 is the relay innitial state in settings + // the latter must not remain set through the shutdown or the system + // will shutdown immediately on startup!!! + MbOK { + id: shutdown + description: qsTr("Shutdown?") + writeAccessLevel: User.AccessUser + onClicked: + { + toast.createToast(qsTr("Shutting down..."), 10000, "icon-restart-active") + if (shutdownItem.valid) + shutdownItem.setValue (1) + if (shutdownItem2.valid) + shutdownItem2.setValue (0) + } + } + + MbSwitch { + property VBusItem hasBuzzer: VBusItem {bind: "com.victronenergy.system/Buzzer/State"} + name: qsTr("Audible alarm") + bind: Utils.path(bindPrefix, "/Settings/Alarm/Audible") + show: hasBuzzer.valid + } + + MbItemOptions { + id: demoOnOff + description: qsTr("Demo mode") + bind: Utils.path(bindPrefix, "/Settings/Gui/DemoMode") + possibleValues: [ + MbOption { description: qsTr("Disabled"); value: 0 }, + MbOption { description: qsTr("ESS demo"); value: 1 }, + MbOption { description: qsTr("Boat/Motorhome demo 1"); value: 2 }, + MbOption { description: qsTr("Boat/Motorhome demo 2"); value: 3 } + ] + } + + MbItemText { + text: qsTr("Starting demo mode will change some settings and the user interface will be unresponsive for a moment.") + wrapMode: Text.WordWrap + } + } +} diff --git a/FileSets/v2.71/PageSettingsGeneral.qml.orig b/FileSets/v2.71/PageSettingsGeneral.qml.orig new file mode 100644 index 0000000..4aa39ec --- /dev/null +++ b/FileSets/v2.71/PageSettingsGeneral.qml.orig @@ -0,0 +1,117 @@ +import QtQuick 1.1 +import com.victron.velib 1.0 +import "utils.js" as Utils + +MbPage +{ + id: root + property string bindPrefix: "com.victronenergy.settings" + + model: VisualItemModel { + MbItemOptions { + id: accessLevelSelect + description: qsTr("Access level") + bind: Utils.path(bindPrefix, "/Settings/System/AccessLevel") + magicKeys: true + writeAccessLevel: User.AccessUser + possibleValues: [ + MbOption { description: qsTr("User"); value: User.AccessUser; password: "ZZZ" }, + MbOption { description: qsTr("User & Installer"); value: User.AccessInstaller; password: "ZZZ" }, + MbOption { description: qsTr("Superuser"); value: User.AccessSuperUser; readonly: true }, + MbOption { description: qsTr("Service"); value: User.AccessService; readonly: true } + ] + + // touch version to get super user + property bool pulledDown: listview.contentY < -60 + Timer { + running: accessLevelSelect.pulledDown + interval: 5000 + onTriggered: if (user.accessLevel >= User.AccessInstaller) accessLevelSelect.item.setValue(User.AccessSuperUser) + } + + // change to super user mode if the right button is pressed for a while + property int repeatCount + onFocusChanged: repeatCount = 0 + + function open() { + if (user.accessLevel >= User.AccessInstaller && ++repeatCount > 60) { + if (accessLevelSelect.value !== User.AccessSuperUser) + accessLevelSelect.item.setValue(User.AccessSuperUser) + repeatCount = 0 + } + } + } + + MbEditBox { + description: "Set root password" + showAccessLevel: User.AccessSuperUser + onEditDone: { + if (newValue.length < 6) { + toast.createToast("Please enter at least 6 characters") + } else { + toast.createToast(vePlatform.setRootPassword(newValue)) + item.value = "" + } + } + } + + MbSwitch { + name: qsTr("SSH on LAN") + showAccessLevel: User.AccessSuperUser + bind: "com.victronenergy.settings/Settings/System/SSHLocal" + } + + MbSwitch { + id: remoteSupportOnOff + name: qsTr("Remote support") + bind: "com.victronenergy.settings/Settings/System/RemoteSupport" + } + + MbItemValue { + description: qsTr("Remote support tunnel") + item.value: remotePort.item.valid && remotePort.item.value !== 0 ? qsTr("Online") : qsTr("Offline") + show: remoteSupportOnOff.item.value + } + + MbItemValue { + id: remotePort + description: qsTr("Remote support IP and port") + item.bind: "com.victronenergy.settings/Settings/System/RemoteSupportIpAndPort" + show: remoteSupportOnOff.item.value + } + + MbOK { + id: reboot + description: qsTr("Reboot?") + writeAccessLevel: User.AccessUser + onClicked: { + toast.createToast(qsTr("Rebooting..."), 10000, "icon-restart-active") + vePlatform.reboot() + } + } + + MbSwitch { + property VBusItem hasBuzzer: VBusItem {bind: "com.victronenergy.system/Buzzer/State"} + name: qsTr("Audible alarm") + bind: Utils.path(bindPrefix, "/Settings/Alarm/Audible") + show: hasBuzzer.valid + } + + MbItemOptions { + id: demoOnOff + description: qsTr("Demo mode") + bind: Utils.path(bindPrefix, "/Settings/Gui/DemoMode") + possibleValues: [ + MbOption { description: qsTr("Disabled"); value: 0 }, + MbOption { description: qsTr("ESS demo"); value: 1 }, + MbOption { description: qsTr("Boat/Motorhome demo 1"); value: 2 }, + MbOption { description: qsTr("Boat/Motorhome demo 2"); value: 3 } + ] + } + + MbItemText { + text: qsTr("Starting demo mode will change some settings and the user interface will be unresponsive for a moment.") + wrapMode: Text.WordWrap + } + } +} diff --git a/GracefulShutdown.sh b/GracefulShutdown.sh new file mode 100755 index 0000000..0310231 --- /dev/null +++ b/GracefulShutdown.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# part of RpiGpioSetup package + +# monitors GPIO pin for shutdown signal (pulled low to shutdown) +# export GPIO pin and set to input +# gpioPin must be in /etc/venus/gpio_list + +# this script runs as a service + +gpioPin=16 + +echo "Raspberry PI gracefull shutdown script starting" + +# echo "$gpioPin" > /sys/class/gpio/export +# echo "in" > /sys/class/gpio/gpio$gpioPin/direction + +# wait for pin to go low +while [ true ] ; do + # if GPIO pin isn't set up, don't do anything + if [ ! -f /sys/class/gpio/gpio$gpioPin/value ]; then + echo "No shutdown GPIO pin defined" + sleep 600 + elif [ "$(cat /sys/class/gpio/gpio$gpioPin/value)" == '1' ] ; then + echo "Raspberry Pi Shutting Down!" + shutdown -h now + sleep 5 100 + exit 0 + fi +sleep 1 +done diff --git a/ReadMe b/ReadMe index 7fa8810..6fd0836 100644 --- a/ReadMe +++ b/ReadMe @@ -6,6 +6,10 @@ This script adds: the additional GPIO pins (5 total) to /etc/venus/gpio_list makes additional digital inputs available makes all digital inputs behave the same: pull up so they are active low + shutdown command to Device List / Settings / General + +To use the shutdown command, pins 38 and 36 of the RPI's GPIO header must be connected + If you don't want the shutdown command to function, do not jumper these pins The Raspberry PI default is for the first 8 GPIO pins to have pull UPs and the remaining have pull DOWNs. This makes some digital input pins behave differently @@ -40,16 +44,16 @@ https://github.com/kwindrem/RpiGpioSetup/archive/current.tar.gz rename the resulting .tar.gz file to venus-data.tar.gz copy the venus-data.tar.gz to a USB stick, put the stick in the Venus device and reboot. -When Venus boots, it will unarchive the file to /data/RpiGoipSetup-current +When Venus boots, it will unarchive the file to /data/RpiGpioSetup-current Move the directory into it's active locaiton: -rm -rf /data/RpiGoipSetup -mv /data/RpiGoipSetup-current /data/RpiGoipSetup +rm -rf /data/RpiGpioSetup +mv /data/RpiGpioSetup-current /data/RpiGpioSetup Repeat the above for SetupHelper if you haven't done so for another package. Finally, run the setup script to complete the installation -/data/RpiGoipSetup/setup +/data/RpiGpioSetup/setup You will need root access to the Venus device. Instructions can be found here: https://www.victronenergy.com/live/ccgx:root_access diff --git a/service/.DS_Store b/service/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..e32a021ba61153863fc9b69c6cf787d078925f3b GIT binary patch literal 6148 zcmeHKOKQU~5S?jK2y~NWmbyYtP&K$G$OVdHNEZqUlQK{VC}jqu zH=d7dJ+MYYM7((&)+P-{j=qii@8Co2y1vvN7I4!(-cIiiWAE^b_xL$&7zhT=49NMAFa)z>Gt{F4lePfBIm{~1^+F3wVgP2xW(W&}Efr{~>@5ac zI_$~gvSTx}bYguo*6}xgH81SfX-*nWoDE|R27-Z02E0jMO8tMtuQb`@U#7%UFc1v< zGX{9xZMzLN<+b(4_N3M(j3*2ciEE-jplc}xYAMEpoFglBnm>sSe|Bt!vWnO>9T*n@ MB_yU`;0g?U0&UYOaR2}S literal 0 HcmV?d00001 diff --git a/service/log/run b/service/log/run new file mode 100755 index 0000000..2860bb2 --- /dev/null +++ b/service/log/run @@ -0,0 +1,3 @@ +#!/bin/sh +exec multilog t s25000 n4 /var/log/gracefulShutdown + diff --git a/service/run b/service/run new file mode 100755 index 0000000..42b2d5b --- /dev/null +++ b/service/run @@ -0,0 +1,4 @@ +#!/bin/sh +exec 2>&1 +exec /data/RpiGpioSetup/GracefulShutdown.sh + diff --git a/setup b/setup index db9514e..e8806af 100755 --- a/setup +++ b/setup @@ -19,12 +19,15 @@ # run manually initally, then called from reinstallMods # to uninstall/deactivate, call this script with "uninstall" as first parameter +# a shutdown command is added to the Settings / General +# the shutdown uses a psudo-digital input jumpered to a psudo-relay output # Note, this script DOES require a system reboot. gpioListFile="/etc/venus/gpio_list" overlayFile="/u-boot/overlays/VenusGpioOverlay.dtb" relayStateFile="/opt/victronenergy/dbus-systemcalc-py/delegates/relaystate.py" configFile="/u-boot/config.txt" +pageGeneralFile="/opt/victronenergy/gui/qml/PageSettingsGeneral.qml" # no log file for this package packageLogFile="" @@ -66,7 +69,22 @@ if [ $scriptAction == 'NONE' ] ; then echo " Activates all 5 predefined digital inputs" echo " Changes all digital inputs to have pull-ups in stead of a mix of pull up/down" - standardActionPrompt + standardActionPrompt 'MORE_PROMPTS' + + # installing (not reinstalling) - prompt for options + if [ $scriptAction == 'NONE' ]; then + echo + echo "An optional shutdown command is added to Settings / General:" + echo " to use this command, RPI GPIO pings 38 and 36 must be connected together" + echo + read -p "Do you wish to install ths shugdown command? (y/n)? " + if $yesResponse ; then + touch "$setupOptionsDir/shutdownCommand" + else + rm -f "$setupOptionsDir/shutdownCommand" + fi + scriptAction='INSTALL' + fi fi #### installing @@ -87,6 +105,15 @@ if [ $scriptAction == 'INSTALL' ] ; then echo "#### end change all digital inputs to pull ups" >> "$configFile" filesUpdated=true fi + + + if [ -f $setupOptionsDir/shutdownCommand ]; then + updateActiveFile "$pageGeneralFile" + installService $packageName + else + restoreActiveFile "$pageGeneralFile" + removeService $packageName + fi fi # uninstalling - check scriptAction again @@ -95,6 +122,8 @@ if [ $scriptAction == 'UNINSTALL' ] ; then restoreActiveFile "$gpioListFile" restoreActiveFile "$overlayFile" restoreActiveFile "$relayStateFile" + restoreActiveFile "$pageGeneralFile" + removeService $packageName # remove mods from configFile - do not use restore in case other mods were made manually if [ -f "$configFile" ]; then diff --git a/timeStamp b/timeStamp index 2ff8399..5979dcc 100644 --- a/timeStamp +++ b/timeStamp @@ -1 +1 @@ -1632614290 +1632854043 diff --git a/version b/version index d9fb9c7..8616689 100644 --- a/version +++ b/version @@ -1 +1 @@ -v3.0 +v3.1