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

IPort Interface

This interface is implemented by virtual serial port driver and represents a virtual serial port device opened by application. It is available as a global port object.

Declaration

interface IPort {

    // Methods
    ${provideReceivedData}(text: string, encoding?: ${Common.Encoding} | number): void;
    ${provideReceivedData#provideReceivedData1}(byte: number): void;
    ${provideReceivedData#provideReceivedData2}(bytes: number[] | Uint8Array | Uint16Array | Uint32Array | ArrayBuffer | DataView): void;
    ${provideReceivedData#provideReceivedData3}(sendAs: ${Port.WriteAs},
        data: number[] | Uint8Array | Uint16Array | Uint32Array | ArrayBuffer | DataView,
        bigEndian?: boolean): void;
    ${getSentData}(maxBytes?: number): Promise<Uint8Array>;
    ${setError}(errorCode: number): void;
    ${setEventMask}(mask: ${Port.EventMask}): void;
    ${clearEventMask}(): void;
}
// This interface is not available in managed environment
// This interface is not available in native environment

IPort Methods

provideReceivedData

provideReceivedData(text: string, encoding?: ${Common.Encoding} | number): void;
// This method is not available in managed environment
// This method is not available in native environment
text
A string to put into a port's input queue.
encoding
String text encoding. Can be either a member of Common.Encoding enumeration or a numeric Windows code page identifier. If omitted, defaults to UTF8 encoding.

Put a given string into port's input queue. An optional encoding parameter, if specified, tells how the port should encode a passed string.

provideReceivedData

provideReceivedData(byte: number): void;
// This method is not available in managed environment
// This method is not available in native environment
byte
A single byte to put into a port's input queue.

Put a single byte into port's input queue.

provideReceivedData

provideReceivedData(bytes: number[] | Uint8Array | Uint16Array | Uint32Array | ArrayBuffer | DataView): void;
// This method is not available in managed environment
// This method is not available in native environment
bytes
An array, typed array, array buffer or DataView object to put into port's input queue.

Put a given data array into port's input queue.

provideReceivedData

provideReceivedData(sendAs: ${Port.WriteAs},
    data: number[] | Uint8Array | Uint16Array | Uint32Array | ArrayBuffer | DataView,
    bigEndian?: boolean): void;
// This method is not available in managed environment
// This method is not available in native environment
sendAs
How to interpret the passed array.
data
An array, typed array, array buffer or DataView object to put into port's input queue. sendAs parameter is used to interpret and possibly convert the passed data array.
bigEndian
If sendAs parameter describes multi-byte sequence, treat is as little-endian (bigEndian equals false or omitted) or as big-endian (bigEndian equals true).

Put a given data array into port's input queue.

getSentData

getSentData(maxBytes?: number): Promise<Uint8Array>;
// This method is not available in managed environment
// This method is not available in native environment
maxBytes
An optional maximum size of the returned buffer.

A promise that is resolved with a copy of the data from the output queue.

Request the data that have been put into the port's output queue by the application. This method must be used by a device script utilizing a pull model.

setError

setError(errorCode: number): void;
// This method is not available in managed environment
// This method is not available in native environment
errorCode
A Win32 error code.

Set the port into the error state. Any pending read sent by application is immediately completed with a passed error code.

setEventMask

setEventMask(mask: ${Port.EventMask}): void;
// This method is not available in managed environment
// This method is not available in native environment
mask
Event mask to set. Can be a combination of flags in Port.EventMask enumeration.

Set the port event mask.

clearEventMask

clearEventMask(): void;
// This method is not available in managed environment
// This method is not available in native environment

Clear the port event mask.