Digilent’s DWF Library wrapper for python
What is this?
This is a python library for controlling Analog Discovery and Electronics Explorer series presetned by Digilent inc. This library needs Waveforms SDK.
I tested this library with Analog Discovery 2 and Waveforms 2015 in below environment.
python 3.5.1, python 2.7.10 on OSX 10.11
python 3.4.3, python 2.7.6 on Ubuntu 14.04LTS
python 3.5.1 on Windows 7
I wrote this library for supporting python 2.6, 2.7, 3.3 or above.
This software is released under the MIT License, see LICENSE.txt.
Installing
You can install the latest stable version from PyPI:
pip install dwf
or if you prefer, install it from this repo like this:
python setup.py install
API of this library
This library has two sets of API. There are Function-based API and Class-based API.
Function-based API
This API is like as C functions which supplied by Digilent. But some modifications are applied for pythonic-way programming.
When error is returned by SDK, the exception DWFError is raised.
All output values, which are passed by reference, are changed to return-value of function.
Arrays of parameters are converted from/to python’s list.
Examples
SDK version check in C language is like as:
char version[32];
FDwfGetVersion(version);
printf("DWF version: %s\n", version);
With this library using function-based API, same code is translated to:
version = dwf.FDwfGetVersion()
print("DWF version: " + version)
Another example is here. This piece of code is quoted from analogout_custom.c in Waveforms SDK sample.
HDWF hdwf;
double rgdSamples[4096];
for (int i = 0; i < 4096; i++) rgdSamples[i] = 2.0*i/4095-1;
FDwfDeviceOpen(-1, &hdwf);
FDwfAnalogOutNodeSet(hdwf, 0, AnalogOutNodeCarrier, true);
FDwfAnalogOutNodeFunctionSet(hdwf, 0, AnalogOutNodeCarrier, funcCustom);
FDwfAnalogOutNodeDataSet(hdwf, 0, AnalogOutNodeCarrier, rgdSamples, 4096);
...
In python with this library, like as:
rgdSamples = []
for i in range(4096): rgdSamples.append(2.0*i/4095-1)
hdwf = dwf.FDwfDeviceOpen()
dwf.FDwfAnalogOutNodeSet(hdwf, 0, dwf.AnalogOutNodeCarrier, True)
dwf.FDwfAnalogOutNodeFunctionSet(hdwf, 0, dwf.AnalogOutNodeCarrier, dwf.funcCustom)
dwf.FDwfAnalogOutNodeDataSet(hdwf, 0, dwf.AnalogOutNodeCarrier, rgdSamples)
...
Class-based API
Class-based APIs are made from function-based APIs. Documents of this API is now writing.
This API has below function and classes.
- DwfEnumeration()
Device enumeration. This function returns list of DwfDevice.
- class DwfDevice
call FDwfEnum*() functions.
- class Dwf
call FDwfDevice*() functions.
- class DwfAnalogIn
call FDwfAnalogIn*() functions.
- class DwfAnalogOut
call FDwfAnalogOut*() functions.
- class DwfAnalogIO
call FDwfAnalogIO*() functions.
- class DwfDigitalIO
call FDwfDigitalIO*() functions.
- class DwfDigitalIn
call FDwfDigitalIn*() functions.
- class DwfDigitalOut
call FDwfDigitalOut*() functions.
With this API, example code is translated to
rgdSamples = []
for i in range(4096): rgdSamples.append(2.0*i/4095-1)
dwf_ao = dwf.DwfAnalogOut()
dwf_ao.nodeSet(0, dwf_ao.NODE.CARRIER, True)
dwf_ao.nodeFunctionSet(0, dwf_ao.NODE.CARRIER, dwf_ao.FUNC.CUSTOM)
dwf_ao.nodeDataSet(0, dwf_ao.NODE.CARRIER, rgdSamples)
...
Metadata
Release files for dwf 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dwf-0.1.0.tar.gz | 26.1 kB | Without provenance | Details for dwf-0.1.0.tar.gz |
Release files / dwf-0.1.0.tar.gz
| Download URL | dwf-0.1.0.tar.gz |
|---|---|
| Size | 26.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd0b5a26f17d0e32f7b390975b15b63dd7606410f1a335314444cdf98eeb5114
|
|
BLAKE2b-256 checksum How to use checksums |
29e14b44033f2c69853d10292c27b9b5e038f50ba04f7ae2907978a90d0f80df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for dwf 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.