# Class Signage#registerRS232CEventListener

Signage

- Defined in: signage.js

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| Signage#registerRS232CEventListener(successCallback, errorCallback, options) Registers event listener to monitor RS232C data.

## Class Detail

Signage#registerRS232CEventListener(successCallback, errorCallback, options)

Registers event listener to monitor RS232C data. To use this function, it needs RS232C connection from external device to signage display. when external device send the RS232C command following the below protocol, SCAP app can receive the data from external device . RS232C Configuration Baudrate : 9600
Data : 8 bit
Parity : none
Stop : 1 bit
Flow Control : none Protocol mediabox_[DATA]_[CHECKSUM] [DATA] : 1 ~ 100 bytes [CHECKSUM]: the last 2 byte hex value after summing all 2 byte hex values in [DATA] For example, external device should send the ASCII data("mediabox_dummy data_E6") to signage display for SCAP app to receive "dummy data" d(0x64) u(0x75) m(0x6d) m(0x6d) y(0x79) SP(0x20) d(0x64) a(0x61) t(0x74) a(0x61) 0x64 + 0x75 + 0x6d + 0x6d + 0x79 + 0x20 + 0x64 + 0x61 + 0x74 + 0x61 = 0x3E6 (the checksum of this data is 'E6')

    // Javascript code
    function registerRS232CEventListener() {
       var eventListener = function(data){
         console.log("received data : " + data.toString());
       };

       var options = {
         eventListener : eventListener
       };

       var successCb = function (){
         console.log("success");
       };

       var failureCb = function(cbObject){
         var errorCode = cbObject.errorCode;
         var errorText = cbObject.errorText;
         console.log( " Error Code [" + errorCode + "]: " + errorText);
       };

       var signage = new Signage();
       signage.registerRS232CEventListener(successCb, failureCb, options);
    }

Parameters:
{Function} successCallback
  success callback function.
{Function} errorCallback
  failure callback function.
{Object} options

  Property | Type | Description | Required
  --- | --- | --- | ---
  eventListener | Function | Event listener to receive data from RS232C port. | required

{Function} options.eventListener
  The function for listening RS232C data. it can receive an event object which contains following property through this function.

  Property | Type | Description | Required
  --- | --- | --- | ---
  data | String | Received data from RS232C port1 ~ 100 bytes | Required

Since:
  1.5
Returns:

  After the method is successfully executed, successCallback is called without any parameter. If an error occurs, errorCallback is called with errorCode and errorText.

See:
  Signage.unregisterRS232CEventListener()