From e7d19c9084a2758cb8ed7de209bc90fd2f963939 Mon Sep 17 00:00:00 2001 From: Daniel Pavel Date: Sun, 28 Apr 2013 14:00:46 +0200 Subject: [PATCH] small fixes to hidconsole --- bin/solaar | 2 +- bin/solaar-cli | 2 +- lib/hidapi/hidconsole.py | 7 +++++-- tools/hidconsole | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/solaar b/bin/solaar index d4c3a8f9..1b5091d2 100755 --- a/bin/solaar +++ b/bin/solaar @@ -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(): diff --git a/bin/solaar-cli b/bin/solaar-cli index 1e1351da..b2ed0d40 100755 --- a/bin/solaar-cli +++ b/bin/solaar-cli @@ -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(): diff --git a/lib/hidapi/hidconsole.py b/lib/hidapi/hidconsole.py index 81512c26..d23beea3 100644 --- a/lib/hidapi/hidconsole.py +++ b/lib/hidapi/hidconsole.py @@ -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)) diff --git a/tools/hidconsole b/tools/hidconsole index 8ea39720..6ca49a75 100755 --- a/tools/hidconsole +++ b/tools/hidconsole @@ -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