(hid_path, buffer)
| 24 | |
| 25 | |
| 26 | def write_to_hid_interface(hid_path, buffer): |
| 27 | # Avoid an unnecessary string formatting call in a write that requires low |
| 28 | # latency. |
| 29 | if logger.getEffectiveLevel() == logging.DEBUG: |
| 30 | logger.debug_sensitive('writing to HID interface %s: %s', hid_path, |
| 31 | ' '.join([f'{x:#04x}' for x in buffer])) |
| 32 | # Writes can hang, for example, when TinyPilot is attempting to write to the |
| 33 | # mouse interface, but the target system has no GUI. To avoid locking up the |
| 34 | # main server process, perform the HID interface I/O in a separate process. |
| 35 | try: |
| 36 | execute.with_timeout(_write_to_hid_interface_immediately, |
| 37 | args=(hid_path, buffer), |
| 38 | timeout_in_seconds=0.5) |
| 39 | except TimeoutError as e: |
| 40 | raise WriteError(f'Failed to write to HID interface: {hid_path}. ' |
| 41 | 'Is USB cable connected?') from e |
nothing calls this directly
no test coverage detected