Skip to content

Commit

Permalink
Fix for reset_usb_devive function
Browse files Browse the repository at this point in the history
  • Loading branch information
allangood committed Apr 15, 2022
1 parent be46f2f commit 320baee
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions rtlamr2mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
# From:
# https://stackoverflow.com/questions/14626395/how-to-properly-convert-a-c-ioctl-call-to-a-python-fcntl-ioctl-call
def reset_usb_device(usbdev):
busnum, devnum = usbdev.split(':')
filename = "/dev/bus/usb/{:03d}/{:03d}".format(int(busnum), int(devnum))
if os.path.exists(filename):
mode = os.stat(filename).st_mode
if S_ISCHR(mode):
if usbdev is not None and ':' in usbdev:
busnum, devnum = usbdev.split(':')
filename = "/dev/bus/usb/{:03d}/{:03d}".format(int(busnum), int(devnum))
if os.path.exists(filename) and S_ISCHR(os.stat(filename).st_mode):
log_message('Reseting USB device: {}'.format(filename))
#define USBDEVFS_RESET _IO('U', 20)
USBDEVFS_RESET = ord('U') << (4*2) | 20
Expand Down

0 comments on commit 320baee

Please sign in to comment.