Package: src:qcontrol
Tags: upstream patch

On Wed, 2013-12-18 at 20:00 +0100, Michael Stapelberg wrote:
> gitorious’s merge request feature is still broken. Find another patch
> attached to this email.

Thanks.

I've bbc'd submit@b.d.o so I don't lose track of this. I'd be more than
happy to receive upstream reports via the Debian BTS in future as well.

Ian.
From f46b219ab0ad1ec38973e7880ee9c61376e3eafa Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <stapelb...@debian.org>
Date: Wed, 18 Dec 2013 19:50:06 +0100
Subject: [PATCH] ts219: implement enabling/disabling RTC (real time clock)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On my TS-119P+, when using the “poweroff” command, the NAS would always
immediately turn back on again. Turns out you need to disable the RTC
(or explicitly set a wake-up date maybe) to get rid of that behavior.
---
 ts219.c |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/ts219.c b/ts219.c
index eea9146..439d7cc 100644
--- a/ts219.c
+++ b/ts219.c
@@ -42,6 +42,9 @@
 #define QNAP_PIC_WOL_ENABLE                     0xF2
 #define QNAP_PIC_WOL_DISABLE                    0xF3
 
+#define QNAP_PIC_RTC_ENABLE                     0xF0
+#define QNAP_PIC_RTC_DISABLE                    0xF1
+
 static int serial;
 static struct termios oldtio, newtio;
 static pthread_t ts219_thread;
@@ -361,6 +364,24 @@ static int ts219_eup(int argc, const char **argv)
 	return 0;
 }
 
+static int ts219_rtc(int argc, const char **argv)
+{
+	unsigned char code = 0;
+
+	if (argc != 1)
+		return -1;
+
+	if (strcmp(argv[0], "on") == 0)
+		code = QNAP_PIC_RTC_ENABLE;
+	else if (strcmp(argv[0], "off") == 0)
+		code = QNAP_PIC_RTC_DISABLE;
+	else
+		return -1;
+
+	serial_write(&code, 1);
+	return 0;
+}
+
 static int ts219_wol(int argc, const char **argv)
 {
 	unsigned char code[2];
@@ -448,6 +469,12 @@ static int ts219_init(int argc, const char **argv UNUSED)
 	                       "\ton\n\toff",
 	                       ts219_eup);
 
+	err = register_command("rtc",
+	                       "Control RTC (real time clock)",
+	                       "Control RTC, options are:\n"
+	                       "\ton\n\toff",
+	                       ts219_rtc);
+
 	return pthread_create(&ts219_thread, NULL, serial_poll, NULL);
 }
 
-- 
1.7.10.4

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to