On 25/04/2025 18:50, Thomas Schmitt wrote:
John Crawley wrote:
[...] a command to emulate the
unplugging and re-plugging of the keyboard would be nice to have.
The internet mentions usbreset(1), available from package "usbutils".
But the source code in
https://sources.debian.org/src/usbutils/1%3A018-2/usbreset.c
shows that the decisive action is a call to ioctl USBDEVFS_RESET, about
which the Linux kernel documentation
https://www.kernel.org/doc/Documentation/driver-api/usb.rst
says
-----------------------------------------------------------------------
USBDEVFS_RESET
Does a USB level device reset. The ioctl parameter is ignored. After
the reset, this rebinds all device interfaces. File modification
time is not updated by this request.
**Warning**
*Avoid using this call* until some usbcore bugs get fixed, since
it does not fully synchronize device, interface, and driver (not
just usbfs) state.
-----------------------------------------------------------------------
The man page is
https://manpages.debian.org/unstable/usbutils/usbreset.1.en.html
Addressing the USB port looks tricky, as it does not work via /dev file
paths.
("Reset by product name" could be a good choice.)
Thank you.
The product name wasn't hard to extract, and
sudo usbreset "ELECOM TK-FCP097"
claimed to be resetting the keyboard, which at least continued to work.
However, after that the terminal went into an endless output of new prompts and
had to be closed.
(The keyboard still works.)
I'll set that command up in a mouse-accessible menu and wait till the next
keyboard dropout to see what it does.
That might not be for a couple of months though, so thanks again.
--
John