# Using the Control\_LW API

Download the AxsunOCTControl\_LW binaries for your desired system architecture and host OS from the links on the [Software Downloads](https://docs.axsun.com/axsun-knowledge-base/other/downloads#axsunoctcontrol_lw-.dll-.so) page.  Then follow the instructions below for installation of additional dependencies according to your host OS and desired communication interfaces.  Finally, run the included example console application to confirm successful installation before integrating the Control\_LW API into your custom application.

## Installing USB Dependencies and Driver

If you plan to use the **AxsunOCTControl\_LW** library for USB-based communication with an Axsun device, follow the installation steps below.  RS-232 or Ethernet-based communication with Axsun devices do not require additional dependencies and the libusb installation and USB Device Driver steps can be skipped.

### libusb

The **AxsunOCTControl\_LW** library uses the [libusb](https://libusb.info) library for communication with Axsun devices connected via USB to a Windows or Linux host computer.  Additional information and installation instructions regarding libusb can be found [here](https://github.com/libusb/libusb/wiki).

#### Windows Installation

[DOWNLOAD ](https://github.com/libusb/libusb/releases/download/v1.0.29/libusb-1.0.29.7z)and extract the pre-built binary and move the file "*libusb-1.0.dll*" into your `C:\Windows\System32` directory (or other location in the loader search path if preferred).

#### Linux Installation

Ubuntu Linux users can install libusb via package manager using the Terminal command:

```bash
sudo apt-get install libusb-1.0-0-dev
```

Installation in other Linux distributions should have an alternative package manager command that can be found via simple online search.

The USB device requires root permissions by default but modified non-root permissions can be achieved in a persistent fashion (across reboots) by creating and saving a new text file named "*axsun.rules*" with the following contents:&#x20;

```
SUBSYSTEM=="usb", ATTRS{idVendor}=="1363", MODE="0666"
SUBSYSTEM=="usb_device", ATTRS{idVendor}=="1363", MODE="0666"
```

and then copying the file to the `/etc/udev/rules.d` directory and triggering a rule update:

```bash
sudo cp axsun.rules /etc/udev/rules.d/
sudo udevadm trigger
```

### USB Device Driver (Windows OS only)

If you plan to use **AxsunOCTControl\_LW** to connect to devices via USB on Windows OS, you must [install the USB device driver](https://docs.axsun.com/axsun-knowledge-base/guides/integrated-engine/installing-software#usb-device-driver) *libusb-win32 v1.2.**6*** or newer (or upgrade the USB device driver to v1.2.6 or newer if an older version was previously installed during installation of [OCT Host](https://docs.axsun.com/axsun-knowledge-base/software-tools/oct-host)).

Following installation of OCT Host (possibly with an older USB driver version), a connected Axsun device (DAQ or Laser Engine) will be displayed in Device Manager as "Axsun OCT Engine" in the "Axsun OCT Devices" device class with "Driver Provider: Axsun" and "Digital Signer: Axsun Technologies, Inc."

<div align="center" data-full-width="false"><img src="https://3144558317-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LP1icDU_wgMhPOYQY7u%2Fuploads%2FM0dneWrvvkFZbtr8WcYF%2Fimage.png?alt=media&#x26;token=e23643c9-56c1-4cb3-aebc-a0b6f13753b4" alt="&#x22;Axsun OCT Engine&#x22; in Device Manager, indicating an older driver which needs to be updated for compatibility with AxsunOCTControl_LW." width="375"></div>

To install or update the newer USB driver for compatibility with AxsunOCTControl\_LW:

* [DOWNLOAD ](https://downloads.axsun.com/public/software/LaserEngine/usb_driver.zip)and extract the .zip on your local disk.
* With the Axsun device connected to the PC via USB and powered-on, run the batch file titled ***RunMeAsAdministrator.bat*** by right-clicking on its icon and selecting the **Run as administrator** menu item.
* Answer **YES** if a Microsoft User Account Control pop-up requests permission to make changes to your computer.
* A terminal window will launch and display the driver installation status.  Press any key to close the terminal window once prompted.

{% hint style="info" %}
**NOTE:** If the USB driver installation is unsuccessful after selecting the **Run as administrator** menu item on the .bat file in Windows Explorer, launch a Command Prompt *as administrator*, change directory to the location of the .bat file on your disk, and execute it directly from the command prompt.
{% endhint %}

Following successful installation, each connected Axsun USB device will appear in Device Manager as "Axsun OCT USB Device" in the "Axsun OCT Devices" class, and the Device Properties window will indicate "Driver Provider: Excelitas Technologies" and "Digital Signer: Excelitas Technologies Corp."

![Device Manager with one Axsun device connected via USB (following USB device driver installation).](https://3144558317-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LP1icDU_wgMhPOYQY7u%2Fuploads%2FmIOyRLZLy6lFDdezvxU9%2Fimage.png?alt=media\&token=65fe8713-782c-495f-9b02-464b5eae0f22)

![Device Properties window for the Axsun OCT USB Device with the updated driver successfully installed.](https://3144558317-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LP1icDU_wgMhPOYQY7u%2Fuploads%2Fn21I5h1ObgDMR810bf2q%2Fimage.png?alt=media\&token=81f0b3bc-e764-487c-adea-235b9676083a)

## Updating C++ Runtime

### Windows

Install the most recent available version of the x64 [Microsoft Visual C++ Redistributable](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist) from [this link](https://aka.ms/vs/17/release/vc_redist.x64.exe).&#x20;

### Linux OS

Depending on the age of your OS and the AxsunOCTControl\_LW library version used, you may need to install an updated version of the [C++ runtime (libstd++.so)](https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html).

For AxsunOCTControl\_LW version 2.0.2 (and older) symbol version **GLIBCXX\_3.4.26** is required.&#x20;

For AxsunOCTControl\_LW version 2.2.0 (and newer) symbol version **GLIBCXX\_3.4.31** is required. &#x20;

Ubuntu 18.04 (or newer) users experiencing errors such as "*GLIBCXX\_3.4.31 not found*" when loading the AxsunOCTControl\_LW shared library can safely upgrade the C++ runtime via the toolchain test PPA:

```bash
sudo apt install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install libstdc++6
```

## Run the Example Console Application

Launch the console application "*AxsunOCTControl\_LW\_Example*" which can be found in the `/bin` directory of the downloaded AxsunOCTControl\_LW package.  If all dependencies and drivers are installed correctly, the console should print something similar to:

<figure><img src="https://3144558317-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LP1icDU_wgMhPOYQY7u%2Fuploads%2Fgs9KCASPxgJOMQMUUyQq%2Fimage.png?alt=media&#x26;token=9cc9a5d0-88e1-493b-990b-1d6560100adf" alt=""><figcaption></figcaption></figure>

and if any Axsun devices are connected to the host system they will be listed as shown:

<figure><img src="https://3144558317-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LP1icDU_wgMhPOYQY7u%2Fuploads%2F83aRTqjsVwfQckOp1rFM%2Fimage.png?alt=media&#x26;token=d82ccd42-f075-4016-8ba5-edb402c9a1a2" alt=""><figcaption></figcaption></figure>

Press "Q" and ENTER to quit the console application.

{% hint style="success" %}
**Congratulations!** You have successfully installed the device driver and dependencies for communicating with your Axsun devices via the AxsunOCTControl\_LW library.  You can now incorporate this library into your client application via the C API or use the [Hardware Control Tool ](https://docs.axsun.com/axsun-knowledge-base/software-tools/hardware-control-tool)to access library functionality in a convenient GUI form.
{% endhint %}

## Integrating Into Your Application

Basic functionality of the AxsunOCTControl\_LW API can be achieved with only several function calls as demonstrated in the [AxsunOCTContro&#x6C;*\_*&#x4C;W Function Reference](https://downloads.axsun.com/public/software/AxsunOCTControl_LW/API_reference/examples.html) example programs.

* The AxsunOCTControl\_LW API is a "plain-old" ANSI C interface which can be directly called from applications coded in native **C or C++**.
* **LabVIEW** integration can be achieved using the [Call Library Function Node](http://zone.ni.com/reference/en-XX/help/371361R-01/glang/call_library_function/). &#x20;
* **C#/.NET Framework** integration can be achieved using P/Invoke and the `DllImport` attribute discussed [here](https://docs.microsoft.com/en-us/cpp/dotnet/using-explicit-pinvoke-in-cpp-dllimport-attribute?view=vs-2017).
* **Python** integration can be achieved using the [ctypes library](https://docs.python.org/3/library/ctypes.html).
