Namespace: serial

ENABLE. serial

Functions for serial connection.

The old namespace ENABLE.tvi has been retained for backward compatibility purposes. However, please note that it will be removed in future versions.

Namespaces

event

Methods

staticENABLE.serial.getSettings(){Object}

tvi.js, line 54

Get serial port settings.

This function retrieves the configuration for the serial port, including
whether serial communication is supported, started, and various operational parameters.

Example return object:

{
    "supported" : true,
    "started" : true,
    "baud_rate" : "9600",
    "intercharacter_time" : "0",
    "binary_mode" : false,
    "status_code" : ""
}
Since:
  • 1.7.0
Returns:
Name Type Description
object Object
Name Type Description
supported Boolean Indicates if serial communication is supported by the device.
started Boolean Whether the serial connection is currently active.
baud_rate Number The baud rate setting for the serial port.
intercharacter_time Number The time between characters in serial transmission.
binary_mode Boolean If the serial port is set to binary mode.
status_code String ENABLE.status.SUCCESS or ENABLE.status.ERROR

staticENABLE.serial.sendMessage(message){Object}

tvi.js, line 120

Send a message via the serial port.
Before sending any message, ensure the serial connection has been started using ENABLE.serial.start.

Name Type Description
message String

The message to send over the serial port.

Since:
  • 1.7.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR

staticENABLE.serial.setEventCallback(callback){Object}

tvi.js, line 150

Register a serial port event callback function.
Only one callback function can be registered. Pass null as callback to unregister.
Example:

var callback = function(obj) {
    if (obj.event === ENABLE.serial.event.MESSAGE){
        console.log("Received serial message");
    }
};
ENABLE.serial.setEventCallback(callback);
Name Type Description
callback ENABLE.serial~Callback

Callback function.

Since:
  • 1.7.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.INVALID_ARGUMENT

staticENABLE.serial.setSettings(object){Object}

tvi.js, line 79

Set serial port settings.

Example for options:

{
    "baud_rate" : 9600,
    "intercharacter_time" : 0,
    "binary_mode" : false
}
Name Type Description
object Object
Name Type Description
baud_rate Number

The baud rate to set for the serial port.

intercharacter_time Number

Time between characters in transmission.

binary_mode Boolean

Whether to use binary mode for the serial port.

Since:
  • 1.7.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR or
ENABLE.status.INVALID_ARGUMENT

staticENABLE.serial.start(){Object}

tvi.js, line 93

Start the serial port connection.

Since:
  • 1.7.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR

staticENABLE.serial.stop(){Object}

tvi.js, line 105

Stop the serial port connection.

Since:
  • 1.7.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR

Type Definitions

Callback(object)

tvi.js, line 124

Callback function for ENABLE.serial.setEventCallback

Name Type Description
object Object
Name Type Description
event Object

Possible values of event:
ENABLE.serial.event.MESSAGE

Since:
  • 1.7.0