taken from http://code.google.com/p/python-xbee/