From d4c802d6f2564bf66a862b93b82f9562741d8c46 Mon Sep 17 00:00:00 2001 From: Rico Schulte Date: Tue, 28 Jul 2009 18:04:08 +0000 Subject: [PATCH] using /dev/input/event2 on dm8000 hardware --- .../src/WebComponents/Sources/RemoteControl.py | 76 ++++++++++++---------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/webinterface/src/WebComponents/Sources/RemoteControl.py b/webinterface/src/WebComponents/Sources/RemoteControl.py index 0dfa02b..035c409 100644 --- a/webinterface/src/WebComponents/Sources/RemoteControl.py +++ b/webinterface/src/WebComponents/Sources/RemoteControl.py @@ -1,40 +1,44 @@ from struct import pack from Components.Sources.Source import Source +from Tools.HardwareInfo import HardwareInfo class RemoteControl(Source): - def __init__(self, session): - self.cmd = None - self.session = session - Source.__init__(self) - self.res = [ False, "Missing or wrong argument" ] - - def handleCommand(self, cmd): - self.cmd = cmd - self.res = self.sendEvent() - - def sendEvent(self): - if self.cmd == "" or self.cmd is None: - print "[RemoteControl.py] cmd is empty or None" - return self.res - - type = int(self.cmd) - if type <= 0: - print "[RemoteControl.py] command <= 0 (%s)" % type - return [ False, "the command was not > 0" ] - - dataon = pack('iiHHi', 0, 0, 1, type, 1) - dataoff = pack('iiHHi', 0, 0, 1, type, 0) - - fp = open("/dev/input/event1", 'wb') - fp.write(dataon) - fp.write(dataoff) - fp.close() - - print "[RemoteControl.py] command was was sent (%s)" % type - return [ True, "command was was sent" ] - - def getResult(self): - return self.res - - - result = property(getResult) + def __init__(self, session): + self.cmd = None + self.session = session + Source.__init__(self) + self.res = [ False, "Missing or wrong argument" ] + + def handleCommand(self, cmd): + self.cmd = cmd + self.res = self.sendEvent() + + def sendEvent(self): + if self.cmd == "" or self.cmd is None: + print "[RemoteControl.py] cmd is empty or None" + return self.res + + type = int(self.cmd) + if type <= 0: + print "[RemoteControl.py] command <= 0 (%s)" % type + return [ False, "the command was not > 0" ] + + dataon = pack('iiHHi', 0, 0, 1, type, 1) + dataoff = pack('iiHHi', 0, 0, 1, type, 0) + + if HardwareInfo.device_name == "dm8000": + fp = open("/dev/input/event2", 'wb') + else: + fp = open("/dev/input/event1", 'wb') + fp.write(dataon) + fp.write(dataoff) + fp.close() + + print "[RemoteControl.py] command was was sent (%s)" % type + return [ True, "command was was sent" ] + + def getResult(self): + return self.res + + + result = property(getResult) -- 2.7.4