uldaq/README.md

147 lines
4.6 KiB
Markdown
Raw Normal View History

2018-05-01 12:02:27 -04:00
## MCC Universal Library for Linux (uldaq)
2018-12-21 13:09:49 -05:00
[![Coverity Scan Build Status](https://scan.coverity.com/projects/16116/badge.svg)](https://scan.coverity.com/projects/uldaq)
2018-12-06 10:43:28 -05:00
**Info:** Contains a library to access and control supported Measurement Computing [DAQ devices](https://www.mccdaq.com/PDFs/Manuals/Linux-hw.pdf) over the Linux and macOS platforms. The UL for Linux binary name is libuldaq.
2018-05-01 12:02:27 -04:00
**Author:** Measurement Computing
## About
2018-12-06 10:43:28 -05:00
The **uldaq** package contains programming libraries and components for developing applications using C/C++ on Linux and macOS Operating Systems. An API (Application Programming Interface) for interacting with the library in Python is available as an additional installation. This package was created and is supported by MCC.
2018-05-01 12:02:27 -04:00
### Prerequisites:
---------------
Building the **uldaq** package requires C/C++ compilers, make tool, and the development package for libusb. The following describes how these prerequisites can be installed on different Linux distributions.
- Debian-based Linux distributions such as Ubuntu, Raspbian
```
$ sudo apt-get install gcc g++ make
$ sudo apt-get install libusb-1.0-0-dev
```
2018-05-03 11:45:25 -04:00
- Arch-based Linux distributions such as Manjaro, Antergos
```
$ sudo pacman -S gcc make
$ sudo pacman -S libusb
```
2018-05-01 12:02:27 -04:00
- Red Hat-based Linux distributions such as Fedora, CentOS
```
$ sudo yum install gcc gcc-c++ make
$ sudo yum install libusbx-devel
2018-05-03 11:45:25 -04:00
```
2018-05-01 12:02:27 -04:00
- OpenSUSE
```
$ sudo zypper install gcc gcc-c++ make
$ sudo zypper install libusb-devel
```
2018-12-06 10:43:28 -05:00
- macOS (Version 10.11 or later recommended)
2018-12-03 13:40:46 -05:00
```
$ xcode-select --install
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew install libusb
```
2018-05-01 12:02:27 -04:00
### Build Instructions
---------------------
1. Download the latest version of **uldaq**:
```
Linux
2018-12-03 13:40:46 -05:00
    $ wget https://github.com/mccdaq/uldaq/releases/download/v1.1.0/libuldaq-1.1.0.tar.bz2
2018-12-06 10:43:28 -05:00
macOS
2018-12-03 13:40:46 -05:00
    $ curl -L -O https://github.com/mccdaq/uldaq/releases/download/v1.1.0/libuldaq-1.1.0.tar.bz2
2018-05-01 12:02:27 -04:00
```
2. Extract the tar file:
```
2018-12-03 13:40:46 -05:00
 $ tar -xvjf libuldaq-1.1.0.tar.bz2
2018-05-01 12:02:27 -04:00
```
3. Run the following commands to build and install the library:
```
2018-12-03 13:40:46 -05:00
 $ cd libuldaq-1.1.0
2018-05-01 12:02:27 -04:00
 $ ./configure && make
$ sudo make install
```
**Note:** To install the Python interface, follow the above [build instructions](#build-instructions) then go to https://pypi.org/project/uldaq/ for further installation.
### Examples
The C examples are located in the examples folder. Run the following commands to execute the analog input example:
```
$ cd examples
$ ./AIn
```
Refer to the **uldaq** [PyPI](https://pypi.org/project/uldaq/) page for instructions on installing Python examples.
### Usage
The following is a basic C example of using the Universal Library for Linux to perform analog input. Further examples are available in the Examples folder.
``` C
#include <stdio.h>
#include "uldaq.h"
#define MAX_DEV_COUNT 100
#define MAX_STR_LENGTH 64
int main(void)
{
unsigned int numDevs = MAX_DEV_COUNT;
DaqDeviceDescriptor devDescriptors[MAX_DEV_COUNT];
DaqDeviceHandle handle = 0;
int chan = 0;
double data = 0;
UlError err = ERR_NO_ERROR;
// Get descriptors for all of the available DAQ devices
ulGetDaqDeviceInventory(ANY_IFC, devDescriptors, &numDevs);
// verify at least one DAQ device is detected
if (numDevs)
{
// get a handle to the DAQ device associated with the first descriptor
handle = ulCreateDaqDevice(devDescriptors[0]);
// check if the DAQ device handle is valid
if (handle)
{
// establish a connection to the DAQ device
err = ulConnectDaqDevice(handle);
// read data for the first 4 analog input channels
for (chan = 0; chan <= 3; chan++)
{
err = ulAIn(handle, chan, AI_SINGLE_ENDED, BIP5VOLTS, AIN_FF_DEFAULT, &data);
printf("Channel(%d) Data: %10.6f\n", chan, data);
}
ulDisconnectDaqDevice(handle);
ulReleaseDaqDevice(handle);
}
}
return 0;
}
```
### Support/Feedback
2018-12-03 13:40:46 -05:00
The **uldaq** package is supported by MCC. For support for uldaq, contact technical support through [support page](https://www.mccdaq.com/support/support_form.aspx). Please include detailed steps on how to reproduce the problem in your request.
2018-05-01 12:02:27 -04:00
### Documentation
Online help for the Universal Library for Linux is available for [C/C++](https://www.mccdaq.com/PDFs/Manuals/UL-Linux/c/index.html) and [Python](https://www.mccdaq.com/PDFs/Manuals/UL-Linux/python/index.html).
If Doxygen is installed and you wish to build the API documentation on your system, run the following commands:
```
$ cd doc
$ doxygen Doxyfile
```