Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New command: qmk console #12828

Merged
merged 32 commits into from
May 9, 2021
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
659b460
stash poc
zvecr May 14, 2020
172978b
stash
zvecr Feb 15, 2021
3c08507
tidy up implementation
zvecr Feb 15, 2021
80df638
Tidy up slightly for review
zvecr Feb 15, 2021
77f1314
Tidy up slightly for review
zvecr Feb 15, 2021
8088043
Bodge environment to make tests pass
zvecr Feb 15, 2021
4534b5d
Refactor away from asyncio due to windows issues
zvecr Feb 16, 2021
933e220
Filter devices
zvecr Feb 19, 2021
ba4e825
align vid/pid printing
zvecr Feb 19, 2021
81fdad3
Add hidapi to the installers
skullydazed May 1, 2021
22b6e1c
start preparing for multiple hid_listeners
skullydazed May 1, 2021
0e47e49
udev rules for hid_listen
skullydazed May 1, 2021
e360b68
refactor to move closer to end state
skullydazed May 2, 2021
60b097c
very basic implementation of the threaded model
skullydazed May 2, 2021
399c8a8
refactor how vid/pid/index are supplied and parsed
skullydazed May 2, 2021
850d129
windows improvements
skullydazed May 2, 2021
5535d6a
read the report directly when usage page isn't available
skullydazed May 2, 2021
7e9c268
add per-device colors, the choice to show names or numbers, and refactor
skullydazed May 3, 2021
f481237
add timestamps
skullydazed May 3, 2021
bf9ad31
Add support for showing bootloaders
skullydazed May 3, 2021
3387ae6
tweak the color for bootloaders
skullydazed May 3, 2021
dfeb0f4
Align bootloader disconnect with connect color
skullydazed May 4, 2021
56eafeb
add support for showing all bootloaders
skullydazed May 7, 2021
4890690
fix the pyusb check
skullydazed May 7, 2021
a4df683
tweaks
skullydazed May 7, 2021
73fa988
fix exception
skullydazed May 7, 2021
da40146
hide a stack trace behind -v
skullydazed May 7, 2021
c42e010
add --no-bootloaders option
skullydazed May 7, 2021
d30fc7c
add documentation for qmk console
skullydazed May 7, 2021
273f7ff
Apply suggestions from code review
skullydazed May 8, 2021
3143d13
pyformat
skullydazed May 8, 2021
ab0d7a3
clean up and flesh out KNOWN_BOOTLOADERS
skullydazed May 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
stash
zvecr authored and skullydazed committed May 1, 2021
commit 172978b335084f25579097436389fc28360ec10c
48 changes: 28 additions & 20 deletions lib/python/qmk/cli/console.py
Original file line number Diff line number Diff line change
@@ -8,15 +8,15 @@
from milc import cli

def patch_linux(dev):
platform_id = platform.platform().lower()
if 'linux' in platform_id:
hidraw = Path(dev['path'].decode('UTF-8')).name
descriptor_path = Path('/sys/class/hidraw/') / hidraw / 'device/report_descriptor'
# platform_id = platform.platform().lower()
# if 'linux' in platform_id:
# hidraw = Path(dev['path'].decode('UTF-8')).name
# descriptor_path = Path('/sys/class/hidraw/') / hidraw / 'device/report_descriptor'

report = descriptor_path.read_bytes()
# report = descriptor_path.read_bytes()

dev['usage_page'] = (report[2] << 8) + report[1];
dev['usage'] = report[4];
# dev['usage_page'] = (report[2] << 8) + report[1];
# dev['usage'] = report[4];
return dev

def is_console_hid(x):
@@ -29,7 +29,7 @@ def search():
@cli.argument('-i', '--index', default=0, type=int, help='Device index.')
@cli.subcommand('kinda hid_listen ish.')
def console(cli):
"""TODO.
"""TODO:
"""

if cli.args.list:
@@ -39,18 +39,26 @@ def console(cli):
cli.log.info("%02x:%02x %s %s", dev['vendor_id'], dev['product_id'], dev['manufacturer_string'], dev['product_string'])
return

print('Waiting for device:')
try:
print('Waiting for device:')

selected = None
while selected is None:
found = search()
selected = found[cli.args.index] if found[cli.args.index:] else None
while True:
selected = None
while selected is None:
found = search()
selected = found[cli.args.index] if found[cli.args.index:] else None
print('.', end = '', flush=True)
sleep(1)

print('.', end = '', flush=True)
sleep(1)
print()
print('Listening to %s:' % selected['path'].decode())
device = hid.Device(path=selected['path'])
try:
while True:
print(device.read(32).decode('ascii'), end = '')

print()
print('Listening to %s:' % selected['path'].decode())
device = hid.Device(path=selected['path'])
while True:
print(device.read(32).decode('ascii'), end = '')
except hid.HIDException:
print('Device disconnected.')
print('Waiting for new device:')
except KeyboardInterrupt:
pass