Options
All
  • Public
  • Public/Protected
  • All
Menu

It represents a serial port resource at the client side.

Hierarchy

  • SerialComm

Index

Constructors

  • Creates an instance of the SerialComm class wiht the specified information.

    Parameters

    • portName: string

      The serial port name, for example COM1.

    • baudRate: number

      The serial port baud rate in bits per second.

    • parity: Parity

      The serial port parity-checking protocol.

    • stopBits: StopBits

      The serial port standard number of stopbits per byte.

    • dataBits: DataBits

      The serial port standard length of data bits per byte.

    • flowControl: Handshake

      The handshaking protocol for serial port transmission of data.

    Returns SerialComm

Properties

SERIAL_TIMEOUT: number = 5000

Accessors

  • get baudRate(): number
  • set baudRate(value: number): void
  • Gets or sets the serial port baud rate in bits per second. Default value is 9600

    Returns number

  • Gets or sets the serial port baud rate in bits per second. Default value is 9600

    Parameters

    • value: number

    Returns void

  • get cts(): Promise<boolean>
  • Gets the state of the Clear-to-Send line. true if the Clear-to-Send line is detected; otherwise, false.

    Returns Promise<boolean>

  • Gets or sets the serial port standard length of data bits per byte. Default value is Serial.DataBits.Eight

    Returns DataBits

  • Gets or sets the serial port standard length of data bits per byte. Default value is Serial.DataBits.Eight

    Parameters

    Returns void

  • get dsr(): Promise<boolean>
  • Gets the state of the Data Set Ready (DSR) signal. true if a Data Set Ready signal has been sent to the port; otherwise, false.

    Returns Promise<boolean>

  • set dtr(value: boolean): void
  • Sets a value that enables the Data Terminal Ready (DTR) signal.

    Parameters

    • value: boolean

    Returns void

  • Gets or sets the handshaking protocol for serial port transmission of data. Default value is Serial.Handshake.XOnXOff

    Returns Handshake

  • Gets or sets the handshaking protocol for serial port transmission of data. Default value is Serial.Handshake.XOnXOff

    Parameters

    Returns void

  • get isOpen(): Boolean
  • Gets whether the port is open.

    Returns Boolean

  • Gets or sets the serial port parity-checking protocol. Default value is Serial.Parity.None

    Returns Parity

  • Gets or sets the serial port parity-checking protocol. Default value is Serial.Parity.None

    Parameters

    Returns void

  • get portName(): string
  • set portName(value: string): void
  • Gets or sets the serial port name, for example COM1. Default value is "COM1"

    Returns string

  • Gets or sets the serial port name, for example COM1. Default value is "COM1"

    Parameters

    • value: string

    Returns void

  • set rts(value: boolean): void
  • Sets a value that enables the Request to Send (RTS) signal.

    Parameters

    • value: boolean

    Returns void

  • Gets or sets the serial port standard number of stopbits per byte. Default value is Serial.StopBits.One

    Returns StopBits

  • Gets or sets the serial port standard number of stopbits per byte. Default value is Serial.StopBits.One

    Parameters

    Returns void

Methods

  • close(): void
  • Closes the port connection

    Returns void

  • onClose(data: any): void
  • Occurs when communication is close.

    Parameters

    • data: any

      The callback function

    Returns void

  • onDataReceived(data: any): void
  • Occurs when data is received.

    Parameters

    • data: any

      The callback function

    Returns void

  • onError(data: any, critical: any): void
  • Occurs when an error is thrown.

    Parameters

    • data: any

      The callback function

    • critical: any

    Returns void

  • open(): Promise<unknown>
  • Opens a new serial port connection

    Returns Promise<unknown>

  • propertiesJSON(): { type: string }
  • Returns { type: string }

    • type: string
  • send(utf8string: string): void
  • Sends the specified string to the serial port.

    Parameters

    • utf8string: string

      The string to send to the serial port.

    Returns void