From 65f72ad2a50388029f11d3c824aee089f5e536e5 Mon Sep 17 00:00:00 2001 From: thewh1teagle <61390950+thewh1teagle@users.noreply.github.com> Date: Sun, 3 Dec 2023 16:23:51 +0200 Subject: [PATCH] fix write --- zero_hid/hid/write.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zero_hid/hid/write.py b/zero_hid/hid/write.py index 086bf85..085b704 100644 --- a/zero_hid/hid/write.py +++ b/zero_hid/hid/write.py @@ -61,10 +61,9 @@ def result(self): def _write_to_hid_interface_immediately(hid_dev, buffer): try: - hid_dev.seek(0, 0) - hid_dev.flush() + hid_dev.seek(0) hid_dev.write(bytearray(buffer)) - + hid_dev.flush() except BlockingIOError: logger.error( f'Failed to write to HID interface: {hid_dev}. Is USB cable connected and Gadget module installed? check https://git.io/J1T7Q' @@ -83,6 +82,7 @@ def write_to_hid_interface(hid_dev, buffer): # Writes can hang, for example, when TinyPilot is attempting to write to the # mouse interface, but the target system has no GUI. To avoid locking up the # main server process, perform the HID interface I/O in a separate process. + write_process = ProcessWithResult( target=_write_to_hid_interface_immediately, args=(hid_dev, buffer),