Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The cec object lets you send messages over CEC (Consumer Electronics Control).

cec IDL

Code Block
languagejs
interface ReceiveEvent {
    attribute String type;
    attribute Array<byte> data;
};

callback ReceiveEventCallback = void (ReceiveEvent event);

interface Cec {
    Promise<void> send(Array<byte> data);
    void addEventListener(String type, ReceiveEventCallback callback);
    void removeEventListener(String type, ReceiveEventCallback callback);
};
Panel
borderColor#3D3D3D
bgColor#F4F4F4
titleColor#3D3D3D
borderWidth0
titleBGColor#3D3D3D
borderStylesolid

ON THIS PAGE

Table of Contents
minLevel1
maxLevel5
outlinefalse
indent20px
typelist
printablefalse



Object Creation

To create a cec object, load the @brightsign/cec module using the require() method. 

Code Block
languagejs
var cecClass = require("@brightsign/cec");
var cec = new cecClass();

Cec

Event

  • ReceiveEvent:  The CEC reception path is implemented as a receive event. The receive message has two generic fields:

    • type:  The event type "receive"

    • data:  Array<byte> CEC frame

Method

send()
Code Block
languagejs
    Promise<void> send(Array<byte> data)

Sends messages over cec.

  • data Array<byte> : The CEC frame

port_name ()
Code Block
languagejs
    Promise<void>

The parameters for this optional argument are:

  • default: The default output for the platform, normally HDMI-1

  • HDMI-X: X is a number from 1 up to the number of HDMI® outputs on the platform

  • eARC: The default for the AU335 

Note

As of BrightSignOS 8.2.55, the CEC implementation for AU series 5 products will reply to these messages with the correct data, without involving the script:

  • CEC_MSG_GET_CEC_VERSION

  • CEC_MSG_ABORT

  • CEC_MSG_GIVE_DEVICE_POWER_STATUS

  • CEC_MSG_GIVE_OSD_NAME

  • CEC_MSG_GIVE_DEVICE_VENDOR_ID

  • CEC_MSG_GIVE_FEATURES

  • CEC_MSG_GIVE_PHYSICAL_ADDR

  • CEC_MSG_USER_CONTROL_PRESSED

  • CEC_MSG_USER_CONTROL_RELEASED

  • CEC_MSG_REPORT_PHYSICAL_ADDR

Example

To send or receive CEC messages:

Code Block
languagejs
    const CecClass = require('@brightsign/cec');
    const cec = new CecClass();

    var initiatorAddress = 0x40;
    var opcodeGetVersion = 0x9f;
    var opcodeVersion = 0x9e;
    var version = "";

    function onRxEvent(packet) {
        let frame = packet.data;
        let opcode = frame[1];
        console.log("Frame Opcode: " + opcode);
        console.log(JSON.stringify(frame));
        if (opcode == opcodeVersion) {
            version = frame[2].toString(16);
            console.log("Version: " + version);
        }
    }

    function cecVersion() {
        return new Promise(async (resolve) => {
            version = "";
            let buffer =[];
            buffer[0] = initiatorAddress;
            buffer[1] = opcodeGetVersion;
            cec.send(buffer)
                .then(async function() {
                    await (async () => new Promise(resolve => setTimeout(resolve, 1000)))();
                    console.log("Version received: " + version);
                    resolve();
                })
                .catch (function(error) {
                    console.log("Ooops: " + error);
                    resolve();
                });
        });
    }

    async function runtest() {
        cec.addEventListener("receive", onRxEvent);
        await cecVersion();
    }