Skip to content

Commit

Permalink
Adding HID permissions testing script.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaklik committed Nov 7, 2024
1 parent 83da7e5 commit 95783d7
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions sw/pymlab_interactive/hid_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import hid

device = None
try:
device = hid.device()
device.open(0x10C4, 0xEA90) # Vendor ID and Product ID for CP2112
print("Device successfully opened")

# Nastavení neblokujícího režimu
device.set_nonblocking(1)

# Odeslání jednoduchého požadavku (např. 0x00)
try:
device.write([0x00]) # Změňte podle protokolu zařízení
print("Request sent.")
except OSError as e:
print("Failed to send request:", e)

# Pokus o čtení odpovědi
data = device.read(64)
if data:
print("Data read:", data)
else:
print("No data received (timeout)")

except OSError as e:
print("Failed to open device:", e)

finally:
if device is not None:
device.close()
print("Device closed")

0 comments on commit 95783d7

Please sign in to comment.