small fixes to hidconsole
This commit is contained in:
parent
638bf38b25
commit
e7d19c9084
|
@ -2,7 +2,7 @@
|
||||||
# -*- python-mode -*-
|
# -*- python-mode -*-
|
||||||
"""Takes care of starting the main function."""
|
"""Takes care of starting the main function."""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
|
|
||||||
def init_paths():
|
def init_paths():
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# -*- python-mode -*-
|
# -*- python-mode -*-
|
||||||
"""Takes care of starting the main function."""
|
"""Takes care of starting the main function."""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
|
|
||||||
def init_paths():
|
def init_paths():
|
||||||
|
|
|
@ -186,6 +186,7 @@ def main():
|
||||||
while t.is_alive():
|
while t.is_alive():
|
||||||
line = read_packet(prompt)
|
line = read_packet(prompt)
|
||||||
line = line.strip().replace(' ', '')
|
line = line.strip().replace(' ', '')
|
||||||
|
# print ("line", line)
|
||||||
if not line:
|
if not line:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -197,16 +198,18 @@ def main():
|
||||||
hidapi.write(handle, data)
|
hidapi.write(handle, data)
|
||||||
# wait for some kind of reply
|
# wait for some kind of reply
|
||||||
if args.hidpp and not interactive:
|
if args.hidpp and not interactive:
|
||||||
|
rlist, wlist, xlist = _select([handle], [], [], 1)
|
||||||
if data[1:2] == b'\xFF':
|
if data[1:2] == b'\xFF':
|
||||||
# the receiver will reply very fast, in a few milliseconds
|
# the receiver will reply very fast, in a few milliseconds
|
||||||
time.sleep(0.010)
|
time.sleep(0.100)
|
||||||
else:
|
else:
|
||||||
# the devices might reply quite slow
|
# the devices might reply quite slow
|
||||||
rlist, wlist, xlist = _select([handle], [], [], 1)
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
except EOFError:
|
except EOFError:
|
||||||
if interactive:
|
if interactive:
|
||||||
print ("")
|
print ("")
|
||||||
|
else:
|
||||||
|
time.sleep(1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print ('%s: %s' % (type(e).__name__, e))
|
print ('%s: %s' % (type(e).__name__, e))
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ def init_paths():
|
||||||
import sys
|
import sys
|
||||||
import os.path as _path
|
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')
|
init_py = _path.join(src_lib, 'hidapi', '__init__.py')
|
||||||
if _path.exists(init_py):
|
if _path.exists(init_py):
|
||||||
sys.path[0] = src_lib
|
sys.path[0] = src_lib
|
||||||
|
|
Loading…
Reference in New Issue