Skip to main content

API for the USB-DUX DAQ boxes for Linux (

Project description

USB-DUX are data acquisition boxes designed for Linux

Installation instructions

Install first the comedi development libraries (if not already on your system):

apt install libcomedi0
apt install libcomedi-dev

and then install pyusbdux (only available for python3):

pip3 install pyusbdux

Quick start guide

Here are the basic steps how to use the API:

# load the module
import pyusbdux as dux

# open comedi

# Start asynchronous data acquisition in the background: one channel, fs=250Hz

# Now we read data at our convenience in a loop or timer or thread
# The following lines need to be repeated

# Let's check if samples are available
if (dux.hasSampleAvilabale() == 0):
      # nope! Do something else or nothing

# Let's get a sample (array of all USB-DUX channels)
sample = dux.getSampleFromBuffer()

# do something with the sample, for example print it

# rinse and repeat!
# end of loop

# shutdown

API documentation

These are the commands which allow you to access the analogue inputs asynchronously and the analogue outputs, digital input and outputs synchronously:

# opens the comedi device with comediDeviceNumber
# returns 0 on success
open()                      # opens 1st comedi device

# Starts acquisition of n_channels at the sampling rate of fs.
# Returns 0 for success and an error code if not successful.
start(n_channels, fs)
start(n_channels)           # at fs=250

# Checks if samples are available (=1) or zero if not.

# Returns one sample from all channels.
# returns always 16 values irrespective of how many channels
# are measured. Blocking call if no samples are available.

# stops the background acquisition

# writes to a digital pin the value 0 or 1
digital_out(channel, value)

# reads from a digital pin

# writes to an analogue output pin (raw ADC values)
analoge_out(channel, value)

# gets the max raw value of the analogue output

# closes the comedi device

# returns the name of the board connected

Any error in comedi throws an exception in python.

Example / demo programs

In the folder are example scripts which show you how to sample data from the analogue and digital ports.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyusbdux, version 1.3.3
Filename, size File type Python version Upload date Hashes
Filename, size pyusbdux-1.3.3.tar.gz (6.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page