small fixes to hidconsole

This commit is contained in:
Daniel Pavel 2013-04-28 14:00:46 +02:00
parent 638bf38b25
commit e7d19c9084
4 changed files with 8 additions and 5 deletions

View File

@ -2,7 +2,7 @@
# -*- python-mode -*-
"""Takes care of starting the main function."""
from __future__ import absolute_import
from __future__ import absolute_import, unicode_literals
def init_paths():

View File

@ -2,7 +2,7 @@
# -*- python-mode -*-
"""Takes care of starting the main function."""
from __future__ import absolute_import
from __future__ import absolute_import, unicode_literals
def init_paths():

View File

@ -186,6 +186,7 @@ def main():
while t.is_alive():
line = read_packet(prompt)
line = line.strip().replace(' ', '')
# print ("line", line)
if not line:
continue
@ -197,16 +198,18 @@ def main():
hidapi.write(handle, data)
# wait for some kind of reply
if args.hidpp and not interactive:
rlist, wlist, xlist = _select([handle], [], [], 1)
if data[1:2] == b'\xFF':
# the receiver will reply very fast, in a few milliseconds
time.sleep(0.010)
time.sleep(0.100)
else:
# the devices might reply quite slow
rlist, wlist, xlist = _select([handle], [], [], 1)
time.sleep(1)
except EOFError:
if interactive:
print ("")
else:
time.sleep(1)
except Exception as e:
print ('%s: %s' % (type(e).__name__, e))

View File

@ -12,7 +12,7 @@ def init_paths():
import sys
import os.path as _path
src_lib = _path.normpath(_path.join(_path.realpath(sys.path[0]), '..', 'src'))
src_lib = _path.normpath(_path.join(_path.realpath(sys.path[0]), '..', 'lib'))
init_py = _path.join(src_lib, 'hidapi', '__init__.py')
if _path.exists(init_py):
sys.path[0] = src_lib