分享

python USB访问模块...

 xiaoqdu 2008-12-10

Python/FTDI-USB module

PyUSB is a python module that interfaces to Future Technology Devices (FTDI) D2XX drivers. FTDI USB chips are used in a variety of USB devices such as USB converters and dongles.

Currently, PyUSB has been tested under MS Windows.

PyUSB is distributed under the GNU Lesser General Public License (LGPL). It is maintained by Pablo Bleyer Kocik. Please email me if you have any questions or if you have found a bug.

If you are looking for a way to use the D2XX driver with Java, you can try the jd2xx package.

News

  • PyUSB 1.6 supports the new FTDI high speed devices.
  • PyUSB 1.5 eeProgram method now accepts a dict object as input instead of keyword arguments.

Download

Documentation

Please use the source and FTDI's FTD2XX Programmers Guide.

Usage

The PyUSB API follows similar guidelines as the D2XX driver, however the behavior has been modified where necessary to fit the Python programming style.

Example

# ----------
# 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)
# ----------

Bugs

No Win32 API compatibility layer functions will be provided. It is better to open a device and pass the handle to the Python for Windows Extension functions.

Copyrights

FTDI D2XX

The D2XX library is Copyright ©2001-2004 Future Technology Devices International Ltd.

PyUSB

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多