コード例 #1
0
ファイル: hidapi_enum.py プロジェクト: bopopescu/web_app
##########################################################################
# Copyright (C) 2014 Mark J. Blair, NF6X
#
# This file is part of pyhidapi.
#
#  pyhidapi is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  pyhidapi is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with pyhidapi.  If not, see <http://www.gnu.org/licenses/>.
##########################################################################
"""Enumerate all HID devices on the system."""

import pyhidapi

if __name__ == '__main__':
    pyhidapi.hid_init()

    print('Loaded hidapi library from: {:s}\n'.format(pyhidapi.hid_lib_path()))

    for dev in pyhidapi.hid_enumerate():
        print('------------------------------------------------------------')
        print(dev.description())
コード例 #2
0
 Example of a slowly beating heart:
  sudo %s -s1 -m5 "  :heart2:    :HEART2:"

-m 9 "Smooth"
-m 10 "Rotate"

 These modes are mentioned in the BMP Badge software.
 Text is shown static, or sometimes (longer texts?) not shown at all.
 One significant difference is: The text of the first message stays visible after
 upload, even if the USB cable remains connected.
 (No "rotation" or "smoothing"(?) effect can be expected, though)
""" % sys.argv[0])
args = parser.parse_args()
if have_pyhidapi:
    devinfo = pyhidapi.hid_enumerate(0x0416, 0x5020)
    #dev = pyhidapi.hid_open(0x0416, 0x5020)
else:
    dev = usb.core.find(idVendor=0x0416, idProduct=0x5020)

if have_pyhidapi:
    if devinfo:
        dev = pyhidapi.hid_open_path(devinfo[0].path)
        print("using [%s %s] int=%d page=%s via pyHIDAPI" %
              (devinfo[0].manufacturer_string, devinfo[0].product_string,
               devinfo[0].interface_number, devinfo[0].usage_page))
    else:
        print("No led tag with vendorID 0x0416 and productID 0x5020 found.")
        print("Connect the led tag and run this tool as root.")
        sys.exit(1)
else:
コード例 #3
0
ファイル: simple_test.py プロジェクト: ampledata/pyhidapi
def test_func():
    pyhidapi.hid_init()
    devs = pyhidapi.hid_enumerate()
    for dev in devs:
        print('---')
        print(dev.description())