Device Monitoring Studio - TODO
Docs

Serial Terminal Session Object

Serial Terminal Session object represents a running terminal session. It implements the ITerminalSession interface. A reference to a session object is obtained through the ITerminalManager.sessions property or ITerminalManager.createSession method.

Configuring Terminal Session

ITerminalManager.createSession receives a session configuration object, which is provided by IDeviceConfig interface. Session's configuration object may be accessed using the property ITerminalSession.config. Once the session is started, this property is read-only and any changes made to the session configuration object's properties are ignored.

You can create a visible terminal session (a session with designated window in UI is provided) or a hidden session (controlled by the ITerminalSession.visible property).

Starting and Stopping Terminal Session

To start a configured session, user script calls the ITerminalSession.start method. To stop, it calls the ITerminalSession.stop method. When the session is stopped, a serial device is closed and may be used by any other application.

Sending Data

Terminal Session object provides a number of methods to send data to the serial device:

MethodDescription
ITerminalSession.sendGeneric method that is overloaded to send an ASCII string, a single byte or a byte array.
ITerminalSession.sendAsSend a given integer array, treating its members as 8-bit, 16-bit, 32-bit or 64-bit integers, with either little-endian or big-endian encoding.
ITerminalSession.sendFileSend the contents of a given file.

All send methods return a promise which must be awaited before trying to send any more data in order to prevent output buffer overflow. If any error occurs, the send method throws an exception.

Receiving Data

To receive data, call the ITerminalSession.receive method. It returns a promise which produces a byte array with available data. Alternatively, a user script may subscribe to the ITerminalSession.received event.

Events

Terminal Session exposes two events: ITerminalSession.sent and ITerminalSession.received. They are fired when new data is sent or received from the device correspondingly.

Flow Control Emulation

A terminal session provides access to various device flow control states. See the corresponding properties and methods of ITerminalSession interface.