Skip to content

Core Framework: HDMI CEC Controller Extension

Ulrond edited this page Dec 30, 2024 · 1 revision

HDMI CEC Controller Extension for raft_framework

This document describes a Python extension for the raft_framework that enables the testing of HDMI CEC devices.

Overview

This extension solves the problem of testing HDMI CEC devices on TVs and Set Top Boxes by providing a way to control and monitor CEC communication through third-party emulators. It offers a high-level class, HDMICECController, that simplifies the integration of CEC testing into development workflows.

Class Documentation

HDMICECController

This class provides a straightforward interface for controlling and monitoring CEC devices. It handles the underlying complexities of CEC communication, allowing you to focus on your testing logic.

  • Initialization:
    • Takes a logger and a configuration dictionary as arguments.
    • The configuration specifies the type of controller to use and the adaptor path.
  • Sending messages: Sends CEC messages to devices on the network.
  • Starting and stopping monitoring: Starts and stops the monitoring of CEC traffic.
  • Reading the monitoring log: Provides a method to read the monitoring log until a specific message is found, which is useful for verifying expected CEC events.
  • Listing devices: Retrieves and lists the discovered CEC devices on the network.

Example Usage:

from framework.core.logModule import logModule
from your_module import HDMICECController, MonitoringType

log = logModule()
config = {
    'type': 'cec-client',  # Specifies the underlying controller type
    'adaptor': '/dev/ttyACM0'  # Path to the CEC adaptor
}
cec = HDMICECController(log, config)

# Send a message
cec.send_message('on 0')  # Example: Send a "power on" command

# Start monitoring CEC traffic
cec.startMonitoring(deviceType=MonitoringType.RECORDER)

# Stop monitoring
cec.stopMonitoring()

# Read the monitoring log until a specific message is found
result = cec.readUntil('standby') 

Integration with Device Manager

The HDMICECController is integrated into a device management system. The device manager will check for an "hdmiCECController" configuration within a device's settings. If present, it can create an instance of HDMICECController using the provided configuration and a logging object.

config = device.get("hdmiCECController")
if config is not None:
    self.hdmiCECController = HDMICECController(log, config)

This allows the device manager to seamlessly use the HDMI CEC controller extension for testing and managing CEC devices.

Conclusion

This extension provides a valuable tool for development engineers working with HDMI CEC devices. It simplifies the process of testing and interacting with CEC devices by providing a user-friendly, high-level interface that hides the underlying implementation details.