Saturday, March 9, 2013

Usb Mail Notifier Python Package

Three years ago I bought a mail notifier from Dealextreme. This USB device is only equipped with and RGB LED and is implementing HID protocol and so do not need any drivers to control.

When received I wanted to only poll my Gmail account each x minutes and according to the colors display my unread email, that worked very nicely until I got a smartphone...
So I unplugged the mail notifier for a long time, in fact until now..

As I am trainning in python, I decided to make a kind of package to handle this device, by creating a library that could be used in your python scripts or as a stand alone binary

Package download:


Old package versions:

Change log:
  * Minor fix add refman.pdf from latex generation, and cosmetic on docs

  * MAJOR fix on pattern restart after being stopped... Was completly broken
  * MAJORs fix on package utilisation as a library
  * Add possibility to the library user to handle device disconnections, and reviving threads on fly by re-'openning' the class

  * Add version information to the package
  * Fix package dir info
  * Minor warning fix

  * Fix pattern exiting to have color off
  * Fix some string formatting
  * Clean common attribute VID/PID COLOR2INT in class
  * RGB args exclusive
  * Logger ability for the library


You need root right to install a new binary and add a udev rule to allow users to access USB device
To note that the package must have pyUSB installed to work, but due to evolution in their API the package is for the moment only compatible with version found on apt repositories (version >=0.4.3-1), the pypi/easy_install/pip version is too young(1.0.0a3).

Untar the package, install dependency, and install it:
tar -xzf USBMailNotifier-v2.4.tar.gz
cd USBMailNotifier-v2.4
sudo apt-get install python-usb
sudo python install
sudo cp usbmailnotifier/udev/30-usbmailnotifier.rules /etc/udev/rules.d/30-usbmailnotifier.rules
Once installed unplug re-plug the usb device so as to udev enable the new rule


usbmailnotify static -sc red
usbmailnotify pattern -sp red yellow lightblue -tp 1.0 1.0 1.0
usbmailnotify pattern -sp off red off red -tp 3.0 0.5 0.5 0.5

More information:

firefox doxygen/html/index.html &
usbmailnotify -h
This package is open source and so can be used as your needs. If you found any suspicious comments within sources don't worry it was surely late when those lines were written...

Doxygen PDF doc: