Skip to content
adajoh99 edited this page Sep 19, 2012 · 3 revisions

Why?

Ihsan Kehribar's Little Wire USB multi-tool comes with a library which has been translated into several languages - C, C++, Processing, etc - but not Python! Python is my language of choice for simple tools development, so I decided to translate it.

What?

This is a (fairly) direct translation of the C version of the library. The function names have been kept the same and the intended functionality is also maintained. The differences from the C library are:

The library is implemented as a class. There is no need to initialise the LittleWire, as the class initialiser does this for you Functions which return a buffer of information return it directly as an array object rather than taking an existing buffer and modifying it - it seems neater to do it this way in Python rather than copy the C paradigm.

How?

To make this library work you will need the following:

  • Python. This has been written and tested with 2.7, but I think it should work across all versions that support Ctypes (needed for pyusb)
  • libusb or libusb-win32 installed on the system. I have used libusb-win32 1.2.6.0 on Windows7 and libusb 1.2.6.0 on Linux, but any version that is compatible with your system should work.
  • pyusb (available from PyPi here)
  • On a Linux system you may need to firk about with the permissions for libusb devices. On my system (Ubuntu 12.04) the default setting for libusb devices meant that root access was required - annoying. There are two solutions to this; either run your python script through sudo so that it has root privileges, or edit your udev permissions. Ladyada has a good description of how to do this (the LittleWire is similar to USBTiny, so the procedure should be the same...)

Where to from here?

Please download and use the library for whatever you wish, and please let me know how you get on! It is largely untested and very much a work in progress at the moment, so I am more than happy to take bug reports.

The files attached below are littleWire.py, which is the main library; and example.py, which is a short example showing how to load and initialise the object and output a 0.5Hz square wave on one pin.

These files are released under the same license as the original C source, which is found in the code.

Clone this wiki locally