Discussion:
[pyusb-users] driving d2xx usb device
i***@gmail.com
2016-02-16 07:37:10 UTC
Permalink
Dear list members

I am a very novice and inexperienced user and I apologize in advance for
what may seem an abomination in the land of python and serial interfaces.

I need to drive a USB device (valve controller) which is operated by
d2xx type ftdi driver.

I installed python 2.6 and original PyUSB module
http://bleyer.org/pyusb/

is it the same PyUSB that is discussed here?

I ran an original short test script

# import the PyUSB module
import d2xx

# list devices by description, returns tuple of attached devices
description strings
d = d2xx.listDevices(d2xx.OPEN_BY_DESCRIPTION)
print d

# list devices by serial, returns tuple of attached devices serial strings
d = d2xx.listDevices() # implicit d2xx.OPEN_BY_SERIAL_NUMBER
print d

h = d2xx.open(0)
print h

# read eeprom
print h.eeRead()

# get queue status
print h.getQueueStatus()

# set RX/TX timeouts
h.setTimeouts(1000,1000)

# write bytes (serial mode)
print h.write('Hello world!\r\n")

# read bytes (serial mode)
print h.read(5)


it seems that my device is visible and here is the output


IDLE 2.6
================================ RESTART
================================
('ValveLink8.2',)
('FTT6NW6D',)
<FtobjType object at 0x01E8D160>
{'useExtOsc': 68, 'ifAIsFifoTar7': 0, 'powerSaveEnable': 149,
'ifBIsFastSer7': 2, 'maxPower': 0, 'bSlowSlew': 0, 'invertTXD': 202,
'manufacturerId': 'FT', 'signature1': 0, 'signature2': -1, 'invertRI':
248, 'cSlowSlew': 1, 'ahSchmittInput': 3, 'dSchmittInput': 0,
'bRIIsTXDEN': 0, 'dIsVCP8': 2, 'ahDriveCurrent': 1, 'vendorId': 1027,
'invertDCD': 2, 'highDriveIOs': 59, 'usbVersionEnable': 1,
'pullDownEnableR': 30, 'endpointSize': 3, 'aRIIsTXDEN': 0, 'invertDSR':
18, 'cRIIsTXDEN': 0, 'bhSlowSlew': 253, 'alSchmittInput': 39, 'version':
2, 'serNumEnableR': 224, 'cSchmittInput': 30, 'ifBIsFastSer': 0,
'usbVersion': 512, 'serNumEnable5': 0, 'isoOut': 0, 'dDriveCurrent': 0,
'invertRTS': 2, 'serNumEnable8': 2, 'manufacturer': 'AutoMate
Scientific', 'cDriveCurrent': 1, 'bDriveCurrent': 3, 'cIsVCP8': 19,
'rIsD2XX': 68, 'ifAIsFifoTar': 0, 'serNumEnable7': 176, 'remoteWakeup':
0, 'bhDriveCurrent': 0, 'cbus0': 23, 'cbus1': 253, 'cbus2': 1, 'cbus3':
232, 'cbus4': 45, 'bIsVCP8': 167, 'alSlowSlew': 245, 'ifAIsFastSer7': 0,
'usbVersion5': 0, 'isoInA': 199, 'isoInB': 18, 'aDriveCurrent': 39,
'bIsVCP7': 180, 'ifAIsFifo': 0, 'bIsVCP': 0, 'selfPowered': 1, 'pnp': 1,
'ahSlowSlew': 51, 'invertCTS': 40, 'alDriveCurrent': 0,
'pullDownEnable': 0, 'bhSchmittInput': 1, 'aSlowSlew': 200, 'invertDTR':
199, 'serNumEnable': 1, 'aIsHighCurrent': 0, 'pullDownEnable8': 133,
'pullDownEnable7': 0, 'pullDownEnable5': 0, 'blDriveCurrent': 23,
'ifAIsFastSer': 0, 'aIsVCP7': 48, 'bSchmittInput': 51, 'ifBIsFifo7':
167, 'aIsVCP8': 48, 'ifBIsFifo': 0, 'isoIn': 0, 'usbVersionEnable5': 0,
'dRIIsTXDEN': 0, 'productId': 54872, 'invertRXD': 133, 'description':
'ValveLink8.2', 'dSlowSlew': 0, 'bIsHighCurrent': 0, 'ifAIsFifo7': 0,
'aIsVCP': 0, 'blSchmittInput': 248, 'rev5': 0, 'ifBIsFifoTar7': 19,
'serialNumber': 'FTT6NW6D', 'blSlowSlew': 30, 'aSchmittInput': 245,
'isoOutA': 2, 'isoOutB': 248, 'ifBIsFifoTar': 0, 'rev4': 1






I also know the control chars that need to be sent to device
to open and close the valves


"\nFv\r" <- toggle valve v, so \nF1\r toggles valve 1
"\nC\r" <- gives the details on the valvelink system, such as the
controller address
"\nI\r" <- Turns off all valves


I modified the script to have

print h.write("\nF2\r")


but nothing happens – the valves do not respond


any help would be vastly appreciated


Thanks!!

Iov
Xiaofan Chen
2016-02-16 07:56:56 UTC
Permalink
Post by i***@gmail.com
Dear list members
I am a very novice and inexperienced user and I apologize in advance for
what may seem an abomination in the land of python and serial interfaces.
I need to drive a USB device (valve controller) which is operated by
d2xx type ftdi driver.
I installed python 2.6 and original PyUSB module
http://bleyer.org/pyusb/
is it the same PyUSB that is discussed here?
No. This pyusb is for Python binding of libusb-0.1, libusb-1.0 and OpenUSB.
https://github.com/walac/pyusb

I think that PyUSB for D2XX is no longer supported by its author and you'd
better to switch to other versions.

Maybe this one?
https://github.com/snmishra/ftd2xx

Or you can forget about d2xx and use pylibftdi or pyftdi.
https://bitbucket.org/codedstructure/pylibftdi
https://github.com/eblot/pyftdi
--
Xiaofan
Tormod Volden
2016-02-16 08:04:07 UTC
Permalink
Post by i***@gmail.com
Dear list members
I am a very novice and inexperienced user and I apologize in advance for
what may seem an abomination in the land of python and serial interfaces.
I need to drive a USB device (valve controller) which is operated by
d2xx type ftdi driver.
I installed python 2.6 and original PyUSB module
http://bleyer.org/pyusb/
is it the same PyUSB that is discussed here?
No, that is not pyusb as we know it here, which is at
http://walac.github.io/pyusb/ "PyUSB aims to be an easy to use Python
module to access USB devices. PyUSB relies on a native system library
for USB access."

I really can't understand why those other guys call their
FTDI-specific library "pyusb"!

Regards,
Tormod

Continue reading on narkive:
Loading...