Skip to content

Audit: Review rcCodes.py & sendKey #122

@Ulrond

Description

@Ulrond

Goal:

  • Review the design of rcCodes.py and check whether there's a better approach. is the enum required, and could the translation table be directly used.
  • Re Review the complete list of rcCodes against the olimex documentation codes, which is the valid supported codes for all current removes, every code should be supported.
  • The config map tables -> see https://github.com/rdkcentral/python_raft/wiki/Common-Remote are used to translate the rcCodes.py into the platform specific codes or the codes that the underlying control model will require.
  • rcCodes.py is used as an input to the keyhandler, and that's not clear from the documentation
sendKey(self, keycode:dict, delay:int=1, repeat:int=1, randomRepeat:int=0)

needs to be clear on the types it requires it's not a dictionary it's an enum from rcCodes.py

sendKey(self, keycode:rcCodes, delay:int=1, repeat:int=1, randomRepeat:int=0)
  • review the keyscodes in the list

There are some odd codes in there which are likely removable, unless they're supported by the remote they shouldn't be present.

This would imply that the rc Module was being used for things that it shouldn't be used for, and therefore these are out of scope for usage.

    RESERVE1 = "RESERVE1"
    DCR = "DCR"
    WIFI_SSID = "WIFI_SSID"
    BLK = "BLK"
    WP = "WP"
    LIGHT_SENSOR = "LIGHT_SENSOR"
    USB = "USB"
    RJ45 = "RJ45"
    RS232 = "RS232"
    RESERVE2 = "RESERVE2"

https://github.com/rdkcentral/python_raft/blob/master/framework/core/rcCodes.py

Upgrade rcCode to have a validation function

Upgrading rcCodes to have a validation function something akin to this seems sensible.

from enum import Enum

class rcCode(Enum):
  SUCCESS = "0"
  FILE_NOT_FOUND = "1"
  # ... other codes

def validate_message_code(code_str):
  try:
    rcCode(code_str)  # Try converting to enum
    return True
  except ValueError:
    return False

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions