Skip to content

Commit

Permalink
Merge pull request #606 from Neradoc/usb-hid-open-binary
Browse files Browse the repository at this point in the history
usb_hid: open in binary does not take an encoding
  • Loading branch information
makermelissa authored Sep 6, 2022
2 parents d70a7ea + 7a3797b commit ad1ec71
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/usb_hid.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def send_report(self, report: bytearray, report_id: int = None):
"""
report_id = report_id or self.report_ids[0]
device_path = self.get_device_path(report_id)
with open(device_path, "rb+", encoding="utf-8") as fd:
with open(device_path, "rb+") as fd:
if report_id > 0:
report = bytearray(report_id.to_bytes(1, "big")) + report
fd.write(report)
Expand All @@ -82,7 +82,7 @@ def get_last_received_report(self, report_id=None) -> bytes:
Return `None` if nothing received.
"""
device_path = self.get_device_path(report_id or self.report_ids[0])
with open(device_path, "rb+", encoding="utf-8") as fd:
with open(device_path, "rb+") as fd:
os.set_blocking(fd.fileno(), False)
report = fd.read(self.out_report_lengths[0])
if report is not None:
Expand Down

0 comments on commit ad1ec71

Please sign in to comment.