Skip to main content
Skip table of contents

GetHandleInfo [LJM User's Guide]

Returns details about a device handle, which is simply a connection ID to an active device.

Syntax

LJM_ERROR_RETURN LJM_GetHandleInfo(
int Handle,
int * DeviceType,
int * ConnectionType,
int * SerialNumber,
int * IPAddress,
int * Port,
int * MaxBytesPerMB)

Parameters

Handle [in]

A device handle. The handle is a connection ID for an active device. Generate a handle with LJM_Open or LJM_OpenS.

DeviceType [out]

The device type corresponding to a constant:

LJM_dtT4 (4) for T4 series device

LJM_dtT7 (7) for T7 series device

LJM_dtT8 (8) for T8 series device

LJM_dtDIGIT (200) for Digit series device

ConnectionType [out]

The connection type corresponding to a constant:

LJM_ctUSB (1) for USB

LJM_ctETHERNET (3) for Ethernet

LJM_ctWIFI (4) for WiFi

SerialNumber [out]

The serial number of the device.

IPAddress [out]

The integer representation of the device's IP address when ConnectionType is TCP-based. Unless ConnectionType is TCP-based, this will be LJM_NO_IP_ADDRESS. Note that this can be converted to a human-readable string with the LJM_NumberToIP function.

Port [out]

The port number when the device connection is TCP-based, or the pipe if the device connection is USB-based.

MaxBytesPerMB [out]

The maximum packet size in number of bytes that can be sent/received from this device. Note that this can change, depending on connection type and device type. This information is important if you are using the low-level functions, or when passing large arrays into other functions.

Returns

LJM errorcodes or 0 for no error.

Remarks

This function is useful to quickly see information about a device handle, such as the serial number, or maximum packet size. In the event that "ANY"-type parameters were used in opening, this function can be used to see which device was actually opened.

This function does not perform device I/O.

Example

Retrieve information about a handle and print it.

C
int LJMError;
int portOrPipe, ipAddress, serialNumber, packetMaxBytes;
int deviceType = LJM_dtANY;
int connectionType = LJM_ctANY;
char string[LJM_STRING_ALLOCATION_SIZE];
char ipAddressString[LJM_IPv4_STRING_SIZE];

LJMError = LJM_GetHandleInfo(handle, &deviceType, &connectionType, &serialNumber, &ipAddress,
    &portOrPipe, &packetMaxBytes);
if (LJMError) {
    LJM_ErrorToString(LJMError, string);
    printf("LJM_GetHandleInfo error: %s (%d)\n", string, LJMError);
}
else {
    printf("deviceType: %d\n", deviceType);
    printf("connectionType: %d\n", connectionType);
    printf("serialNumber: %d\n", serialNumber);

    if (connectionType == LJM_ctETHERNET || connectionType == LJM_ctWIFI) {
        LJM_NumberToIP(ipAddress, ipAddressString);
        printf("IP address: %s\n", ipAddressString);
    }

    if (connectionType == LJM_ctUSB) {
        printf("pipe: %d\n", portOrPipe);
    }
    else {
        printf("port: %d\n", portOrPipe);
    }

    printf("The maximum number of bytes you can send to or receive from this device in one packet is %d bytes.\n",
        packetMaxBytes);
}
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.