Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set_startup_time() wildcard is broken #4

Open
imammedo opened this issue Jul 19, 2020 · 0 comments
Open

set_startup_time() wildcard is broken #4

imammedo opened this issue Jul 19, 2020 · 0 comments

Comments

@imammedo
Copy link

When trying using '??' wildcard it produces errors like
-bash: 10#%%/1016+(10#%%%10): syntax error: operand expected (error token is "%/1016+(10#%%%10)")

it also happens when using it indirectly trying to set startup timer with wittyPi.sh using '5. Schedule next startup'
and if wildcard is set correctly menu #5 doesn't recognize that, saying that "Auto startup time is not set yet."

the same issue applies to set_shutdown_time().

below patch fixes set_startup_time()/set_shutdown_time() functions, fixing wittyPi.sh and the rest I'll leave up to you.
(issue is due to using special symbol '?' without paying attention how it's expanded in parameters)

--- wittypi/utilities.sh.orig	2020-07-19 21:32:48.820942463 +0200
+++ wittypi/utilities.sh	2020-07-19 21:34:30.979628928 +0200
@@ -265,25 + @@
 set_startup_time()
 {
   i2c_write 0x01 $I2C_RTC_ADDRESS 0x0E 0x07
-  if [ $4 == '??' ]; then
+  if [ "$4" == '??' ]; then
     sec='128'
   else
     sec=$(dec2bcd $4)
   fi
   i2c_write 0x01 $I2C_RTC_ADDRESS 0x07 $sec
-  if [ $3 == '??' ]; then
+  if [ "$3" == '??' ]; then
     min='128'
   else
     min=$(dec2bcd $3)
   fi
   i2c_write 0x01 $I2C_RTC_ADDRESS 0x08 $min
-  if [ $2 == '??' ]; then
+  if [ "$2" == '??' ]; then
     hour='128'
   else
     hour=$(dec2bcd $2)
   fi
   i2c_write 0x01 $I2C_RTC_ADDRESS 0x09 $hour
-  if [ $1 == '??' ]; then
+  if [ "$1" == '??' ]; then
     date='128'
   else
     date=$(dec2bcd $1)
@@ -319,19 +319,19 @@
 set_shutdown_time()
 {
   i2c_write 0x01 $I2C_RTC_ADDRESS 0x0E 0x07
-  if [ $3 == '??' ]; then
+  if [ "$3" == '??' ]; then
     min='128'
   else
     min=$(dec2bcd $3)
   fi
   i2c_write 0x01 $I2C_RTC_ADDRESS 0x0B $min
-  if [ $2 == '??' ]; then
+  if [ "$2" == '??' ]; then
     hour='128'
   else
     hour=$(dec2bcd $2)
   fi
   i2c_write 0x01 $I2C_RTC_ADDRESS 0x0C $hour
-  if [ $1 == '??' ]; then
+  if [ "$1" == '??' ]; then
     date='128'
   else
     date=$(dec2bcd $1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant