मुझे cython-hidapi (pip install hidapi
के रूप में स्थापित करने योग्य) का उपयोग करके एक साधारण परीक्षण मिल गया - ध्यान दें कि यह टिप्पणियों में लिंक किए गए एक से अलग है लेकिन फ़ंक्शन में समान लगता है)। मैंने मैकपोर्ट से hidapi-devel
भी स्थापित किया था लेकिन मुझे यकीन नहीं है कि यह आवश्यक है क्योंकि यह बंदरगाह को निष्क्रिय करने के बाद काम करना जारी रखता है।
उदाहरण try.py संशोधित VID उपयोग करने के लिए इनके द्वारा/एक Microsoft यूएसबी वायरलेस कीबोर्ड/माउस डिवाइस के पीआईडी इस प्रकार
from __future__ import print_function
import hid
import time
print("Opening the device")
h = hid.device()
h.open(1118, 2048) # A Microsoft wireless combo keyboard & mouse
print("Manufacturer: %s" % h.get_manufacturer_string())
print("Product: %s" % h.get_product_string())
print("Serial No: %s" % h.get_serial_number_string())
try:
while True:
d = h.read(64)
if d:
print('read: "{}"'.format(d))
finally:
print("Closing the device")
h.close()
और $ sudo python try.py
के साथ चल मैं निम्नलिखित उत्पादन प्राप्त करने में सक्षम था के रूप में:
Opening the device
Manufacturer: Microsoft
Product: Microsoft® Nano Transceiver v2.0
Serial No: None
read: "[0, 0, 0, 0, 0, 0, 0, 0]"
read: "[0, 0, 0, 0, 0, 0, 0, 0]"
read: "[0, 0, 0, 0, 0, 0, 0, 0]"
--8<-- snip lots of repeated lines --8<--
read: "[0, 0, 0, 0, 0, 0, 0, 0]"
read: "[0, 0, 0, 0, 0, 0, 0, 0]"
read: "[0, 0, 21, 0, 0, 0, 0, 0]"
read: "[0, 0, 21, 0, 0, 0, 0, 0]"
read: "[0, 0, 21, 0, 0, 0, 0, 0]"
read: "[0, 0, 21, 0, 0, 0, 0, 0]"
read: "[0, 0, 0, 0, 0, 0, 0, 0]"
read: "[0, 0, 4, 0, 0, 0, 0, 0]"
read: "[0, 0, 4, 22, 0, 0, 0, 0]"
read: "[0, 0, 4, 22, 0, 0, 0, 0]"
read: "[0, 0, 4, 22, 0, 0, 0, 0]"
read: "[0, 0, 4, 22, 0, 0, 0, 0]"
read: "[0, 0, 4, 22, 0, 0, 0, 0]"
read: "[0, 0, 4, 0, 0, 0, 0, 0]"
read: "[0, 0, 4, 0, 0, 0, 0, 0]"
read: "[0, 0, 4, 9, 0, 0, 0, 0]"
read: "[0, 0, 4, 9, 0, 0, 0, 0]"
read: "[0, 0, 4, 9, 0, 0, 0, 0]"
read: "[0, 0, 4, 9, 0, 0, 0, 0]"
read: "[0, 0, 4, 9, 7, 0, 0, 0]"
read: "[0, 0, 4, 9, 7, 0, 0, 0]"
read: "[0, 0, 7, 0, 0, 0, 0, 0]"
^CClosing the device
Traceback (most recent call last):
File "try.py", line 17, in <module>
d = h.read(64)
KeyboardInterrupt
मैं जिस विशेष डिवाइस का उपयोग कर रहा हूं वह कुंजीपटल & माउस के लिए अन्य चीजों के साथ कई छुपा उपकरणों के रूप में गिनती प्रतीत होता है, इसलिए ऐसा लगता है कि आपको थोड़ा यादृच्छिक लगता है, लेकिन बारकोड स्कैनर के लिए यह बहुत सीधे आगे होना चाहिए।
कोई जवाब नहीं, लेकिन मुझे [यह] (http://www.signal11.us/oss/hidapi/) और 'ioreg -rtn IOHIDKeyboard' आदेश मिला। – Potatoswatter
क्या आपने https://github.com/apmorton/pyhidapi कोशिश की है? – pigletfly