Class EthernetDevice

Represents a single Ethernet device. Each Ethernet device hosts a web server, and the base URL uniquely identifies the device.

Hierarchy

  • EthernetDevice

Constructors

Properties

baseUrl: string

The base URL for accessing the device API.

headers: {
    Accept: string;
    Content-Type: string;
} = ...

Default headers for all requests to the Integro device web server.

Type declaration

  • Accept: string
  • Content-Type: string

A collection of previously retrieved device parameters. These cached parameters assist in determining the correct data type and decoding parameter values during parameter upload. They are also used to identify the list of PDO entries and their configurations.

rxPdoEntries?: EthernetPdoEntry[]

Cached RxPDO entries used to determine the type and size when sending PDO values.

txPdoEntries?: EthernetPdoEntry[]

Cached TxPDO entries used to determine the type and size when receiving PDO values.

Methods

  • Clears the internal cache by resetting parameters and PDO entries.

    This method sets the parameters, rxPdoEntries, and txPdoEntries to undefined, effectively clearing any stored configuration or data for these properties.

    Returns void

  • Downloads the specified parameter value to the device.

    Command Code: CMD=0x02

    Returns

    A promise that resolves when the download is complete.

    Parameters

    • index: number

      The index of the parameter to be downloaded.

    • subindex: number

      The subindex of the parameter to be downloaded.

    • value: ParameterValueType

      The value to set for the parameter.

    • Optional uid: string

      An optional unique identifier for the request.

    Returns Promise<void>

  • Retrieves and caches PDO entries, including index, subindex, bit length, and data type, for efficient reuse in operations like sending and receiving PDO values.

    Note that requests to NetX must be made sequentially; otherwise, a fetch call in Node.js may time out, resulting in a 'ConnectTimeoutError'.

    Returns

    A promise that resolves to an array of cached PDO entries.

    Parameters

    • key: "rxPdoEntries" | "txPdoEntries"

      Specifies which PDO entries to retrieve ('rxPdoEntries' or 'txPdoEntries').

    Returns Promise<EthernetPdoEntry[]>

  • Retrieves the EtherCAT-compatible state of the device as defined by EthercatState.

    Command Code: CMD=0x06

    Returns

    A promise that resolves to the current state as a number.

    Parameters

    • Optional uid: string

      An optional unique identifier for the request.

    Returns Promise<number>

  • Parses a single entry (array of strings) representing information about a parameter from the GET /odl endpoint. For example, the following entry corresponds to "0x2111:1" (Encoder 1 feedback - Raw position): [ "2111", // Index in hexadecimal format "1", // Subindex in decimal format "Raw position", // Parameter name "0", // Object code "7", // Value type "87" // Flags ]

    Returns

    An object of type EthernetDeviceParameter containing the parsed values.

    Parameters

    • entry: string[]

      An array of strings containing the parameter information.

    Returns EthernetDeviceParameter

  • Reads a file from the specified device.

    Command Code: CMD=0x03

    Todo

    Implement the function to fetch the file data from the device.

    Returns

    A promise that resolves to a Uint8Array containing the file data.

    Parameters

    • filename: string

      The name of the file to be read.

    • Optional uid: string

      An optional unique identifier for the request.

    Returns Promise<Uint8Array>

  • Receives PDO values from the device.

    The device sends an array of bytes, and this function processes the parameters, their data types, and the PDO entries to convert the byte array into an array of received PDO entry values.

    Command Code: CMD=0x0A

    Returns

    An array of received PDO entry values.

    Parameters

    • Optional uid: string

      An optional unique identifier for the request.

    Returns Promise<number[]>

  • Resets or restarts both NetX firmware components: COM and CORE. This operation is typically performed after completing a firmware installation.

    Note that the device will respond before the actual restart occurs, so please allow a few seconds for the restart to complete.

    Command Code: CMD=0x09

    Returns

    A promise that resolves when the reset request is complete.

    Parameters

    • Optional clearCache: boolean = true

      Specifies whether to clear the parameters and PDO entries cache during the reset.

    Returns Promise<void>

  • Send PDO values to the device.

    The provided array of values will be converted into a byte array based on parameters' data types.

    Command Code: CMD=0x0B

    Returns

    Parameters

    • values: number[]
    • Optional uid: string

    Returns Promise<void>

  • Updates the firmware by uploading it to the device and restarting the NetX.

    Todo

    This function has not been tested. Verify its functionality by uploading a firmware file.

    Parameters

    • buffer: ArrayBuffer

      The firmware data to upload.

    • filename: string

      The name of the firmware file.

    Returns Promise<void>

  • Uploads a single parameter value from the device.

    Command Code: CMD=0x01

    Returns

    • A promise that resolves with the uploaded parameter value.

    Parameters

    • index: number

      The index of the parameter to upload.

    • subindex: number

      The subindex of the parameter to upload.

    • Optional uid: string

      An optional unique identifier for the request.

    Returns Promise<ParameterValueType>

  • Uploads the firmware file to the device. Call the reset method to apply the changes.

    Todo

    This function has not been tested. Verify its functionality by uploading a firmware file.

    Returns

    A promise that resolves when the upload is complete.

    Parameters

    • buffer: ArrayBuffer

      The firmware data to upload.

    • filename: string

      The name of the firmware file.

    Returns Promise<void>

  • Writes the specified file content to the device.

    Command Code: CMD=0x04

    Todo

    Implement the function to write the file content to the device.

    Returns

    A promise that resolves when the file has been successfully written.

    Parameters

    • filename: string

      The name of the file to be created or overwritten on the device.

    • content: Uint8Array

      The file content to be written, provided as a Uint8Array.

    • Optional uid: string

      An optional unique identifier for the request.

    Returns Promise<void>

Generated using TypeDoc