From 8ff897375f6957dc4762c1001a6325260eb994b3 Mon Sep 17 00:00:00 2001 From: sheikhmishar Date: Wed, 22 Nov 2023 08:14:43 +0600 Subject: [PATCH 1/2] Added Windows support --- README.md | 3 +++ fnirsi_logger.py | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 979396b..ac59c34 100644 --- a/README.md +++ b/README.md @@ -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 ------- diff --git a/fnirsi_logger.py b/fnirsi_logger.py index 91fed5a..719b05b 100755 --- a/fnirsi_logger.py +++ b/fnirsi_logger.py @@ -2,6 +2,7 @@ import sys import time +from os import name as os_name import usb.core import usb.util @@ -77,12 +78,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): From 313eb1507839c8f506af1a028ff558d8a2030da4 Mon Sep 17 00:00:00 2001 From: sheikhmishar Date: Wed, 22 Nov 2023 08:20:54 +0600 Subject: [PATCH 2/2] removed os detection as NotImplemented Exception is handled --- fnirsi_logger.py | 1 - 1 file changed, 1 deletion(-) diff --git a/fnirsi_logger.py b/fnirsi_logger.py index 719b05b..339641a 100755 --- a/fnirsi_logger.py +++ b/fnirsi_logger.py @@ -2,7 +2,6 @@ import sys import time -from os import name as os_name import usb.core import usb.util