Virtual Serial Port Tools - Advanced serial port configurations for your custom ports usage scenario
Download Virtual Serial Port Tools Hide this button

Device Script API Overview

This section provides detailed API documentation for a device script, a script that powers up a script port virtual serial device.

Device Script API is fully asynchronous, most methods and some properties return promise objects. Promises are resolved when appropriate events happen, make sure your code properly work with asynchronous calls. It is recommended to mark your functions that call those methods with async keyword and use the await operator. A callback model is also supported, you can query continuations using the Promise.then method.

NOTE

This script execution context is created after the port is opened and is destroyed as soon as it is closed. Any global variables you create will only live this long.

That is, you cannot store any state between port opening attempts. However, the execution context is guaranteed to exist until the port is closed by the application. Anyway, prefer storing any state in the created device script object, not on a global scope.

Global Object

Methods and properties defined on a Global object are described in the IGlobals topic.

File System Object

Global file system object (implemented as IFileManager interface) provides convenient access to the local file system, allowing the device script to read and store data in files, create or delete files and folders as well as enumerate the contents of a folder.

Network Object

The network object (implemented as INetworkManager interface) provides a way to create TCP and UDP sockets, connect or bind them and perform a data transfer over the network.

HTTP Object

The Http object (implemented as IHttpClient interface) provides the ability for a device script to make HTTP requests to query and control remote HTTP resources.