mirror of
https://github.com/undera/pylgbst.git
synced 2020-11-18 19:37:26 -08:00
* Cosmetics * Harmonograph demo * Cleanup * Original * Original * Cosmetics * Original file * Fixes * cosmetics * separate classes * Cosmetics * Cosmetics * fix tests * Remove plotter tests * Add bluegiga * Rename it * Progress * Fix tests * Cosmetics * Found a way for pygatt! * Playing with gatt * Fix hung subscribe * rename class * add test * skeleton for autodetect * safer order * Fix tests * Fix test * Add dbus install * another try * 2 * 3 * 34 * 6 * 7 * Isolate some tests * 8 * back to roots * Try more * 9 * Help * rep * site-packs * Fix? * Py3 come on * dbus * busss * dev null! * Fix test * Cleanup * Fix tests * Fix after review * add package * FIx package paths * Cosmetics * Update * More doc
27 lines
527 B
Python
27 lines
527 B
Python
"""
|
|
This module offers some utilities, in a way they are work in both Python 2 and 3
|
|
"""
|
|
|
|
import binascii
|
|
import sys
|
|
from struct import unpack
|
|
|
|
if sys.version_info[0] == 2:
|
|
import Queue as queue
|
|
else:
|
|
import queue as queue
|
|
|
|
queue = queue # just to use it
|
|
|
|
|
|
def usbyte(seq, index):
|
|
return unpack("<B", seq[index:index + 1])[0]
|
|
|
|
|
|
def ushort(seq, index):
|
|
return unpack("<H", seq[index:index + 2])[0]
|
|
|
|
|
|
def str2hex(data): # we need it for python 2+3 compatibility
|
|
return binascii.hexlify(data).decode("utf8")
|