Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions framework/core/commonRemote.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,15 @@ def __decodeRemoteMapConfig(self):
keyDictionary = config.get('remoteMaps',{})
return keyDictionary

def sendKey(self, keycode:dict, delay:int=1, repeat:int=1, randomRepeat:int=0):
def sendKey(self, keycode:dict, delay:int=1, repeat:int=1, randomRepeat:int=0, holdInterval:int=0):
"""Send a key to the remoteCommander

Args:
keycode (dict): Key value pair
delay (int, optional): Delay in seconds between repeats. Defaults to 1.
repeat (int, optional): How many key repeats. Defaults to 1.
randomRepeat (int, optional): Random Key repeat value. Defaults to 0.
holdInterval (int, optional): Hold the key for specified delay. Defaults to 0.
Comment thread
mshameersm marked this conversation as resolved.
"""
if (randomRepeat != 0):
import random
Expand All @@ -181,7 +182,7 @@ def sendKey(self, keycode:dict, delay:int=1, repeat:int=1, randomRepeat:int=0):
self.log.info( "sendKey[" + keycode.name + "] delay:[" +str(delay)+"]" )

mappedCode = self.remoteMap.getMappedKey( keycode.name )
result = self.remoteController.sendKey( mappedCode, repeat, delay)
result = self.remoteController.sendKey( mappedCode, repeat, delay, holdInterval)
Comment thread
mshameersm marked this conversation as resolved.
return result

def setKeyMap( self, name:dict ):
Expand Down
3 changes: 2 additions & 1 deletion framework/core/remoteControllerModules/arduino.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ def __init__( self, log:logModule, remoteConfig:dict() ):
self.arduino = serial.Serial(port=self.remoteConfig.get("port"), baudrate=self.remoteConfig.get("baudrate"), timeout=300)
self.firstKeyPressInTc = True

def sendKey(self, key, repeat=1, delay=1):
def sendKey(self, key, repeat=1, delay=1, holdInterval=0):
"""Send IR key using arduino module

Args:
key (str) - Key to be sent to device#
repeat (int) - Number of times the key has to be pressed. Defaults to 1
delay (int) - wait time after pressing the key
holdInterval (int): How long to wait between key presses.
Comment thread
mshameersm marked this conversation as resolved.
"""
if self.firstKeyPressInTc:
time.sleep(5)
Expand Down
18 changes: 8 additions & 10 deletions framework/core/remoteControllerModules/keySimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,25 @@ def __init__(self, log: logModule, remoteConfig: dict):
prompt=self.prompt
)

def sendKey(self, key: str, repeat: int, delay: int):
def sendKey(self, key: str, repeat: int=0, delay: int=1, holdInterval: int=0):
"""Send a key command with specified repeats and interval.

Args:
key (str): The key to send.
repeat (int): Number of times to send the key.
delay (int): Delay between key presses in seconds.
holdInterval (int): How long to wait between key presses.
Comment thread
mshameersm marked this conversation as resolved.
Comment thread
mshameersm marked this conversation as resolved.

Returns:
bool: Result of the command verification.
"""
finalResult = True

# Send the key command
for _ in range(repeat):
self.session.write("")
self.session.write(f"keySimulator -k{key}", wait_for_prompt=True)
time.sleep(delay)
output = self.session.read_until(self.prompt, timeout=10)
if self.prompt not in output:
self.log.error(f"Failed to send key: {key}")
finalResult = False
break
self.session.write("")
self.session.write(f"keySimulator -k{key} -i{delay} -r{repeat} -p{holdInterval}", wait_for_prompt=True)
output = self.session.read_until(self.prompt, timeout=30)
if self.prompt not in output:
self.log.error(f"Failed to send key: {key}")
finalResult = False
return finalResult
5 changes: 3 additions & 2 deletions framework/core/remoteControllerModules/none.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ def __init__( self, log:logModule, remoteConfig:dict):
"""
self.log = log

def sendKey(self, code:str, repeat:int, delay:int ):
def sendKey(self, code:str, repeat:int, delay:int, holdInterval:int ):
Comment thread
mshameersm marked this conversation as resolved.
"""Send a key

Args:
code (str): keycode
repeat (int): number of repeats required
delay (int): delay in seconds between repeats
holdInterval (int): How long to wait between key presses.

Returns:
bool: true on success otherwise failure
Expand All @@ -58,7 +59,7 @@ def sendKey(self, code:str, repeat:int, delay:int ):
return False

for _ in range(repeat):
self.log.info("remoteNone: sendKey( code=[{}] repeat=[{}] delay=[{}] )".format( code, repeat, delay ) )
self.log.info("remoteNone: sendKey( code=[{}] repeat=[{}] delay=[{}] holdInterval=[{}] )".format( code, repeat, delay, holdInterval ) )
time.sleep( delay )

return True
2 changes: 1 addition & 1 deletion framework/core/remoteControllerModules/olimex.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def command(self, cmd:str):
self.telnet.disconnect()
return True

def sendKey(self, code:str, repeat:int, delay:int ):
def sendKey(self, code:str, repeat:int, delay:int, holdInterval:int):
if code == None:
return False

Expand Down
2 changes: 1 addition & 1 deletion framework/core/remoteControllerModules/redrat.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __init__(self, log: logModule, config: dict):
self._client.start(self._hub_ip, hub_port=self._hub_port, netbox_id=self._netbox_id)
self._output = config.get('output', 1)

def sendKey(self, code, repeat, delay):
def sendKey(self, code, repeat, delay, holdInterval):
msg = f'{self._netbox_id_type}="{self._netbox_id}" {code} output="{self._output}"'
for _ in range(repeat):
if 'OK' not in self._client.send_message(msg):
Expand Down
3 changes: 2 additions & 1 deletion framework/core/remoteControllerModules/remoteInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ def __init__( self, log:logModule, remoteConfig:dict):
self._config = remoteConfig

@abstractmethod
def sendKey(self, code:str, repeat:int, delay:int ):
def sendKey(self, code:str, repeat:int, delay:int, holdInterval:int ):
"""Send a key

Args:
code (str): keycode
repeat (int): number of repeats required
delay (int): delay in seconds between repeats
holdInterval (int): How long to wait between key presses.
Comment thread
mshameersm marked this conversation as resolved.

Returns:
bool: true on success otherwise failure
Expand Down
2 changes: 1 addition & 1 deletion framework/core/remoteControllerModules/skyProc.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def command(self, cmd):
self.telnet.disconnect()
return True

def sendKey(self, code, repeat, delay ):
def sendKey(self, code, repeat, delay, holdInterval ):

# Run the key sendKey via the terminal
command="echo " + str(code) + " > /proc/cdi_ir"
Expand Down
Loading