OPL-SDK Programmer's Guide and DLL Function Documentation

Table of Contents

  1. Prerequisites
  2. General Conventions
    1. Data Types
    2. Parameters By-Value or By-Reference
    3. Function Aliases
  3. Unit Model Compatibility
  4. Control of Multiple Devices
  5. Thread Safety



Prerequisites

Prior to being able to program with the DLLs and communicate with the OPXXX series units, the USB drivers must be installed. The USB driver is an intermediary and facilitates the USB to serial communication from the DLL to the unit and vice versa. For the drivers and instructions on how to install them, please visit http://www.optotest.com or contact optotest customer service at customerservice@optotest.com.

The OPLxxxM.DLL must be placed in a location within the search path of the executable that is referencing it. This is typically in the root folder of the executable itself or in the System32 or SysWoW64 folder depending on executable and OS bitness.

General Conventions

The DLLs themselves are writtin in Delphi/Pascal, as such, this documentation is based on Delphi/Pascal syntax. For cross-language compatibility, the functions use the STDCALL calling convention.

Data Types

The following table shows the data type equivalents in various common programming languages:

integer

signed 32-bit integer

byte

unsigned 8-bit integer

word

unsigned 16-bit integer

uint32

unsigned 32-bit integer; used for 32-bit USB Handle

puint32

pointer to 32-bit unsigned integer; used for 32-bit USB Handle

uint64

unsigned 64-bit integer; used for 64-bit USB Handle

puint64

pointer to 64-bit unsigned integer; used for 64-bit USB Handle

double

8-byte double precision floating point

pansichar

pointer to character (8-bit) array; used for c-strings


Parameters By-Value or By-Reference

Language

by-value

by-reference

Delphi/Pascal

value

var variable

Visual Basic

byVal value

byRef variable

C/C++

value

&variable

Visual C#

value

ref variable


Function Aliases

Each function can be called either with the "OPXXX_" prefix or without. For example, the "OP930_RemoteMode" function can also be called using just "RemoteMode". Some functions may have other aliases and will be noted in their description.

Unit Model Compatibility

DLL

Model

OP710M.DLL

OP710, OP712, OP735

OP720M.DLL

OP720, OP721, OP722

OP815M.DLL

OP715*, OP815, OP831, OP925

OP930M.DLL

OP930, OP940

*Compatibility depends on hardware configuration.

Control of Multiple Devices

Multiple devices can be connected to the computer if the computer itself has multiple USB ports or by connecting to an external USB hub. Multiple hubs can be cascaded per manufacturer's specifications.

When controlling multiple OptoTest devices, the following sequence is recommended (replace the "OP710_" prefix as needed):

  1. Query how many devices are active on the USB using OP710_GetUSBDeviceCount.

  2. Iterate through the devices by device number from 0 to device count from the previous step and filter by model using OP710_GetUSBDeviceDescription.

  3. Use OP710_GetUSBSerialNumber to get the Serial Number, which is a unique identifier, for each of the filtered devices.

  4. Take the device number that has the desired Serial Number and use OP710_OpenUSBDevice with that device number to open the device and get the USB Handle.

  5. Use the USB Handle from the previous step with OP710_OpenDriver open and initialize the instrument driver.

It is recommended to use the information from the sequence above to build a look-up table of device number to serial number and USB handles. This will facilitate switching control of devices using OP710_SelectModule.

To switch between devices, do the following:

  1. Use the created look-up table to get the device number that corresponds to a specific serial number.

  2. Use OP710_SelectModule with the device number to make that device the Active Device.

  3. Send commands to the Active Device.

  4. Repeat 1-3 to select and send commands to a different device.



Thread Safety

These functions are not thread-safe. Please exercise caution when using it in a threaded application. Make sure only 1 thread or asynchronous process is communicating to a unit at a time to avoid miscommunications.


Generated by PasDoc 0.15.0.