"…mais ce serait peut-être l'une des plus grandes opportunités manquées de notre époque si le logiciel libre ne libérait rien d'autre que du code…"

Archive for the ‘Operating Systems’ Category

An other ctypes based python module : pyUSB 1.0 (alpha) is out !

Posted by patrick sur avril 22, 2010

http://pyusb.sourceforge.net
http://pyusb.sourceforge.net/docs/1.0/tutorial.html 

=======================================
PyUSB 1.0 – Easy USB access from Python
=======================================

Introduction
============

The PyUSB module provides Python with easy access to the host
machine’s Universal Serial Bus (USB) system.

Until 0.4 version, PyUSB used to be a thin wrapper aroung libusb.
With 1.0 version, things changed considerably. Now PyUSB is an
API rich, backend neutral Python USB module easy to use.

As with most Python modules, PyUSB’s documentation is based on Python
doc strings and can therefore be manipulated by tools such as pydoc.

You can also find a tutorial at: http://pyusb.sourceforge.net/docs/1.0/tutorial.html.

PyUSB is being developed and tested in Linux and Windows, but it should work
fine in any platform running Python >= 2.3, ctypes and at least one of the
builtin backends.

PyUSB supports libusb 0.1, libusb 1.0 and OpenUSB, but the user does not need
to worry about that, unless in some corner cases.

If you have any question about PyUSB, you can use the PyUSB mailing list
hosted in the SourceForge. In the PyUSB website (http://pyusb.sourceforge.net)
you can find instructions on how to subscribe to the mailing list.

Installing PyUSB on GNU/Linux Systems
=====================================

These instructions are for Debian-based systems.  Instructions for
other flavors of GNU/Linux should be similar.

You will first need to install the following packages:

1) python (PyUSB is useless without it), version >= 2.3
2) At least one of the supported libraries (libusb 1.0, libusb 0.1 or OpenUSB)
3) If your Python version is < 2.5, you have to install ctypes as a separate package,
because these versions of Python does not ship it.

For example, the command

sudo apt-get install python libusb

should install all these packages on most Debian-based systems with
access to the proper package repositories.

Once the above packages are installed, you can install PyUSB
with the command

python setup.py install

run as root from within the same directory as this README file.

Installing PyUSB on Windows
===========================

Now that PyUSB is 100% written in Python, you install it on Windows
in the same way you do on Linux, but libusb for Windows is done
through libusb-win32 package (libusb 1.0 backend is in progress).
To install it you do as usual:

python setup.py install

Reporting bugs/Submitting patches
=================================

Some people have been sending me patches and reporting bugs directly
in my email. Please, do it through SourceForge tracker, I had
a hardtime tracking their names to put them in the acknowledgments file. 😉

PS: this README file was based on the great Josh Lifton’s one… ^_^

import usb.core
import usb.util

# find our device
dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)

# was it found?
if dev is None:
    raise ValueError('Device not found')

# set the active configuration. With no arguments, the first
# configuration will be the active one
dev.set_configuration()

# get an endpoint instance
ep = usb.util.find_descriptor(
        dev.get_interface_altsetting(),   # first interface
        # match the first OUT endpoint
        custom_match = \
            lambda e: \
                usb.util.endpoint_direction(e.bEndpointAddress) == \
                usb.util.ENDPOINT_OUT
    )

assert ep is not None

# write the data
ep.write('test')

Voir aussi

  • http://docs.python.org/library/ctypes.html (‘ctypes is a foreign function library for Python. It provides C compatible data types, and allows calling functions in DLLs or shared libraries. It can be used to wrap these libraries in pure Python’)
  • http://pypi.python.org/pypi/jaraco.windows/1.8 (‘jaraco.windows aims to provide a pure-python interface to Windows APIs using ctypes. This package is not designed to be exhaustive, but rather to supply interfaces as they are needed by the contributors.’)

Posted in 2010, ctypes, Operating Systems, python, USB | Tagué: , | Leave a Comment »

Quelques liens sur le développement de pilotes USB sous GNU/Linux: Greg Kroah-Hartman, Daniel Drake, fprint, libusb, pylibusb, lsusb.py, LDD3

Posted by patrick sur mars 22, 2010

http://archive.netbsd.se/?ml=&a=2009-01&t=6220842

FYI, this is a patch that will be sent out in the next round to Linus
for inclusion in 2.6.25.

If anyone has any objections about it, please let me know.

thanks,

greg k-h

--------

From: Greg Kroah-Hartman
Subject: USB: mark USB drivers as being GPL only

Over two years ago, the Linux USB developers stated that they believed
there was no way to create a USB kernel driver that was not under the
GPL.  This patch moves the USB apis to enforce that decision.

There are no known closed source USB drivers in the wild, so this patch
should cause no problems.

Signed-off-by: Greg Kroah-Hartman

Over two years ago, the Linux USB developers stated that they believed
there was no way to create a USB kernel driver that was not under the GPL.
This patch moves the USB apis to enforce that decision.

The USB subsystem has changed a lot over time, and it has been possible
to create userspace USB drivers using usbfs/libusb/gadgetfs that operate
as fast as the USB bus allows.  Because of this, the USB subsystem will
not be allowing closed source kernel drivers to register with it, after
this grace period is over.  If anyone needs any help in converting their
closed source drivers over to use the userspace filesystems, please
contact the linux-usb-<email removed> mailing list, and the developers
there will be glad to help you out. Greg Kroah-Hartman


linux kernel

linux drivers

usb vendor id (VID), product ID

python usb module

libusb library

fprint library depends on libusb

  • http://www.reactivated.net/ (‘My fprint efforts lead to me adopting the libusb project. I am working on libusb-1.0 which will offer new features allowing for more powerful applications’)
  • http://www.reactivated.net/fprint/wiki/Main_Page (« The fprint project aims to plug a gap in the Linux desktop: support for consumer fingerprint reader devices »)
  • http://www.reactivated.net/fprint/wiki/Libfprint

    • Written in C
    • Licensed as LGPL-2.1
    • Depends on libusb for USB communication and glib
    • Primarily developed for linux, but should be fairly portable
    • Offers a single API to application developers to access the entire range of supported devices
    • Supports imaging – downloading live fingerprint scans from the device
    • Includes image processing/matching code
    • Supports enrollment/verification – enrolling a print from a known user, and then later comparing a live scan to the enrolled print

				

Posted in 2010, Années, Drivers, Git, libusb, USB | Tagué: , , , , , , , | Leave a Comment »

Quelques modules python et autres bibliothèques C à voir : Turk, buildbot, graphy, bpython, pyUSB, pylibusb, libusb, libfprint, lsusb.py, labjacku12 python usb driver

Posted by patrick sur mars 21, 2010

  • http://pypi.python.org/pypi/Turk/0.1.1 (« A framework for interfacing applications and devices with the web.  NOTE: You need dbus and python-dbus installed first. If there’s no precompiled package for your system, get them from:
from graphy.backends import google_chart_api

monthly_rainfall = [3.2, 3.2, 2.7, 0.9, 0.4, 0.1, 0.0, 0.0, 0.2, 0.9, 1.8, 2.3]
months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split()

chart = google_chart_api.LineChart(monthly_rainfall)
chart.bottom.labels = months
print chart.display.Img(400, 100)

Posted in Drivers, libusb, logiciel libre, Operating Systems, USB | Tagué: , , , , , , , , , | Leave a Comment »