Exemple #1
0
def get_descriptor(path):
    for dev in uhid_freebsd.enumerate():
        if dev["path"] == path:
            vid = dev["vendor_id"]
            pid = dev["product_id"]
            return _read_descriptor(vid, pid, path)
    raise ValueError("Device not found")
Exemple #2
0
def get_descriptor(path):
    for dev in uhid_freebsd.enumerate():
        if dev["path"] == path:
            vid = dev["vendor_id"]
            pid = dev["product_id"]
            name = dev["product_desc"] or None
            serial = (dev["serial_number"]
                      if "serial_number" in dev else None) or None
            return _read_descriptor(vid, pid, name, serial, path)
    raise ValueError("Device not found")
Exemple #3
0
def list_descriptors():
    descriptors = []
    for dev in uhid_freebsd.enumerate():
        try:
            descriptors.append(
                _read_descriptor(dev["vendor_id"], dev["product_id"], dev["path"])
            )
        except Exception as e:
            logger.debug("Failed opening HID device", exc_info=e)

    return descriptors
 def Enumerate():
     for dev in uhid_freebsd.enumerate():
         desc = linux.base.DeviceDescriptor()
         desc.path = dev["path"]
         desc.vendor_id = dev["vendor_id"]
         desc.product_id = dev["product_id"]
         desc.product_string = dev["product_desc"]
         fd = os.open(desc.path, os.O_RDONLY)
         linux.ParseReportDescriptor(uhid_freebsd.get_report_data(fd, 3),
                                     desc)
         os.close(fd)
         yield desc.ToPublicDict()
Exemple #5
0
def list_descriptors():
    descriptors = []
    for dev in uhid_freebsd.enumerate():
        try:
            descriptors.append(
                _read_descriptor(dev["vendor_id"], dev["product_id"], dev["path"])
            )
            logger.debug("Found CTAP device: %s", dev["path"])
        except ValueError:
            pass  # Not a CTAP device, ignore
        except Exception as e:
            logger.debug("Failed opening HID device", exc_info=e)

    return descriptors
Exemple #6
0
def list_descriptors():
    descriptors = []
    for dev in uhid_freebsd.enumerate():
        try:
            name = dev["product_desc"] or None
            serial = (dev["serial_number"]
                      if "serial_number" in dev else None) or None
            descriptors.append(
                _read_descriptor(
                    dev["vendor_id"],
                    dev["product_id"],
                    name,
                    serial,
                    dev["path"],
                ))
            logger.debug("Found CTAP device: %s", dev["path"])
        except ValueError:
            pass  # Not a CTAP device, ignore
        except Exception as e:
            logger.debug("Failed opening HID device", exc_info=e)

    return descriptors
Exemple #7
0
from __future__ import print_function

import uhid_freebsd as uhid
import os

for dev in uhid.enumerate():
    print("Device:", dev["device"])
    print("  Path:", dev["path"])
    print("  VendorId: 0x%04x" % dev["vendor_id"])
    print("  ProductId: 0x%04x" % dev["product_id"])
    print("  ProductDesc:", dev["product_desc"])
    fd = os.open(dev["path"], os.O_RDONLY)
    out = uhid.get_report_data(fd, 3)
    os.close(fd)
    print("  ReportData: " + " ".join([("%02x" % (x)) for x in out]))