Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Windows support #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ In Debian/Ubuntu: `sudo apt-get install python3-usb`.
Alternatively `python3 -m pip install pyusb crc` should also work and
get you latest version.

For Windows, copy "libusb-1.0.dll" to the same directory as fnirsi_logger.py
and add to PATH by running `set "PATH=PATH_TO_libusb-1.0.dll;%PATH%"`. There
are other ways. But, this will get you running without hassle.

Running
-------
Expand Down
15 changes: 9 additions & 6 deletions fnirsi_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,15 @@ def find_hid_interface_num(dev):


def ensure_interface_not_busy(dev, interface):
if dev.is_kernel_driver_active(interface.bInterfaceNumber):
try:
dev.detach_kernel_driver(interface.bInterfaceNumber)
except usb.core.USBError as e:
print(f"Could not detatch kernel driver from interface({interface.bInterfaceNumber}): {e}", file=sys.stderr)
sys.exit(1)
try:
if dev.is_kernel_driver_active(interface.bInterfaceNumber):
try:
dev.detach_kernel_driver(interface.bInterfaceNumber)
except usb.core.USBError as e:
print(f"Could not detatch kernel driver from interface({interface.bInterfaceNumber}): {e}", file=sys.stderr)
sys.exit(1)
except NotImplementedError as e:
print(f"Feature not implemented in your operating system or kernel: {e}", file=sys.stderr)


def ensure_all_interfaces_not_busy(dev):
Expand Down