Package: qcontrol
Version: 0.4.2-1
Severity: wishlist
Tags: patch
All ARM based QNAP machines can turn on automatically when power is
applied if the device was not powered down correctly. This is helpful
when your power goes down.
The patch below adds support for this feature. Since upstream is
currently not responsive, it would be great if you could apply it to
the Debian package.
Thanks.
diff -u qcontrol-0.4.2/ts219.c qcontrol-0.4.2/ts219.c
--- qcontrol-0.4.2/ts219.c
+++ qcontrol-0.4.2/ts219.c
@@ -285,6 +285,24 @@
return 0;
}
+static int ts219_autopower(int argc, const char **argv)
+{
+ char code = 0;
+
+ if (argc != 1)
+ return -1;
+
+ if (strcmp(argv[0], "on") == 0)
+ code = 0x48;
+ else if (strcmp(argv[0], "off") == 0)
+ code = 0x49;
+ else
+ return -1;
+
+ return serial_write(&code, 1);
+ return 0;
+}
+
int ts219_init(int argc, const char **argv)
{
int err;
@@ -325,6 +343,11 @@
"Set the usbled, options are:\n"
"\ton\n\t8hz\n\toff\n",
ts219_usbled);
+ err = register_command("autopower",
+ "Control the automatic power mechanism",
+ "Control the automatic power mechanism, options
are:\n"
+ "\ton\n\toff\n",
+ ts219_autopower);
return pthread_create(&ts219_thread, NULL, serial_poll, NULL);
}
--- qcontrol-0.4.2.orig/ts209.c
+++ qcontrol-0.4.2/ts209.c
@@ -273,6 +273,24 @@
return 0;
}
+static int ts209_autopower(int argc, const char **argv)
+{
+ char code = 0;
+
+ if (argc != 1)
+ return -1;
+
+ if (strcmp(argv[0], "on") == 0)
+ code = 0x48;
+ else if (strcmp(argv[0], "off") == 0)
+ code = 0x49;
+ else
+ return -1;
+
+ return serial_write(&code, 1);
+ return 0;
+}
+
int ts209_init(int argc, const char **argv)
{
int err;
@@ -313,6 +331,11 @@
"Set the usbled, options are:\n"
"\ton\n\t8hz\n\toff\n",
ts209_usbled);
+ err = register_command("autopower",
+ "Control the automatic power mechanism",
+ "Control the automatic power mechanism, options
are:\n"
+ "\ton\n\toff\n",
+ ts209_autopower);
return pthread_create(&ts209_thread, NULL, serial_poll, NULL);
}
only in patch2:
unchanged:
--- qcontrol-0.4.2.orig/ts409.c
+++ qcontrol-0.4.2/ts409.c
@@ -263,6 +263,24 @@
return 0;
}
+static int ts409_autopower(int argc, const char **argv)
+{
+ char code = 0;
+
+ if (argc != 1)
+ return -1;
+
+ if (strcmp(argv[0], "on") == 0)
+ code = 0x48;
+ else if (strcmp(argv[0], "off") == 0)
+ code = 0x49;
+ else
+ return -1;
+
+ return serial_write(&code, 1);
+ return 0;
+}
+
int ts409_init(int argc, const char **argv)
{
int err;
@@ -298,6 +316,11 @@
"Set the usbled, options are:\n"
"\ton\n\t8hz\n\toff\n",
ts409_usbled);
+ err = register_command("autopower",
+ "Control the automatic power mechanism",
+ "Control the automatic power mechanism, options
are:\n"
+ "\ton\n\toff\n",
+ ts409_autopower);
return pthread_create(&ts409_thread, NULL, serial_poll, NULL);
}
--
Martin Michlmayr
http://www.cyrius.com/
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]