MCPcopy Index your code
hub / github.com/tiny-pilot/tinypilot / write_to_hid_interface

Function write_to_hid_interface

app/hid/write.py:26–41  ·  view source on GitHub ↗
(hid_path, buffer)

Source from the content-addressed store, hash-verified

24
25
26def 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

Callers

nothing calls this directly

Calls 2

WriteErrorClass · 0.85
debug_sensitiveMethod · 0.80

Tested by

no test coverage detected