Using the USB-1024HLS Digital I/O from Python
| tags: programming
ctypes makes it really easy to control the USB-1024HLS Digital I/O box from python.
This gets the 2 functions I need and tests to see if the device is there
import ctypes
UL = ctypes.windll.cbw32
cbDConfigPort = UL.cbDConfigPort
cbDOut = UL.cbDOut
FIRSTPORTA = 10
FIRSTPORTB = 11
FIRSTPORTCL = 12
FIRSTPORTCH = 13
DIGITALOUT = 1
DIGITALIN = 2
port = FIRSTPORTA
try:
assert cbDConfigPort(0, port, DIGITALOUT) == 0
except AssertionError:
print 'Configuration of the USB-1024HLS failed'
Then to send data, I simply
cbDOut(0, port, bits)