ssCore.SerialIO.setNotify

Tell SWF Studio about a serial event that you'd like to receive notifications for.


Availability:

First available in version 3.8 build 333.


Input Parameters:

event - The name of the event notification you want enabled. Valid values include: onReceive,onReceiveBinary.


Output Parameters:

result - Notification data for the specified event (see description of events for more detail).


Asynchronous Mode:

When this method is called asynchronously, a return object containing the output parameters is passed to the specified callback function.

ssCore.SerialIO.setNotify( paramsObject [, callbackParamsObject] [, errorParamsObject] );


Synchronous Mode:

When this method is called synchronously, a return object containing the output parameters is returned to the caller immediately.

var returnObject = ssCore.SerialIO.setNotify( paramsObject );


Notes:

name - onReceive
type - triggered
result - text_data

The onReceive event is triggered when data is received on the serial port. The data is interpreted as plain text. If the data contains binary zeros it may be truncated. Use the onBinaryDataReceived event for reading binary data.

ssCore.SerialIO.setNotify({event:"onReceive"}, {callback:onReceiveHandler});

function onReceiveHandler(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        sDebug.trace("data: " + ret_obj.result);
    }
}

name - onReceiveBinary
type - triggered
result - binary_data

The onReceiveBinary event is triggered when data is received on the serial port. The data is interpreted as binary data and is returned in hex tring format.

ssCore.SerialIO.setNotify({event:"onReceiveBinary"}, {callback:onReceiveBinaryHandler});

function onReceiveBinaryHandler(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
     // binary data is in hex string format
ssDebug.trace("data: " + ret_obj.result);
    }
}

name - onInfoReceived
type - triggered
result - info_message

The onInfoReceived event is triggered when the serial port enters a state that requires notifying you. The following are the possible values for the informational message:

BREAK - A break was detected on input. br /> RING - The ring indicator was set to high. Only transitions from low to high will trigger this event.
CTSON or CTSOFF - A change in the CTS (clear to send) line.
DSRON or DSROFF - A change in the DSR (data set ready) line.
RLSDON or RLSDOFF - A change in the RLS (receive line signal detect) ) line. This is also known as the DCD (data carrier detect) line, which is turned on when a modem receives a sigal from another modem.

ssCore.SerialIO.setNotify({event:"onInfoReceived"}, {callback:onInfoReceivedHandler});

function onInfoReceivedHandler(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        ssDebug.trace("info: " + ret_obj.result);
    }
}

name - onReceiveError
type - triggered
result - error_message

The onReceiveError event is triggered when an error is detected on the serial port. The following are the possible values for the error message:

BREAK - Break condition detected.
FRAME - Framing error.
IOERROR - I/O device error.
MODE - Unsupported mode.
OVERRUN - A character buffer overrun has been detected, the next byte is lost.
RXOVER - An input buffer overflow has been detected, a byte has been lost.
RXPARITY - Input parity error.
TXFULL - The output buffer is full.
UNKNOWN - Unknown error.

ssCore.SerialIO.setNotify({event:"onReceiveError"}, {callback:onReceiveErrorHandler});

function onReceiveErrorHandler(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        ssDebug.trace("error: " + ret_obj.result);
    }
}