Skip to content

Commit

Permalink
fix write
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Dec 3, 2023
1 parent a526777 commit 65f72ad
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions zero_hid/hid/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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),
Expand Down

0 comments on commit 65f72ad

Please sign in to comment.