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.
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).
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.
Terminal Session object provides a number of methods to send data to the serial device:
|ITerminalSession.send||Generic method that is overloaded to send an ASCII string, a single byte or a byte array.|
|ITerminalSession.sendAs||Send 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.sendFile||Send 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.
To receive data from serial port, 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.
A terminal session provides access to various serial device flow control states. See the corresponding properties and methods of ITerminalSession interface.