USB port restart

Sometimes the USB connection with the ADRD-m1-10 is lost. Here you can find a solution on how to restart the USB connection programmatically , without the necessity of unplugging the cable.

Windows solution

  4. Finally, run $devcon.exe restart "@PATH" , substitute "PATH" with the line saved from the previous step.


Linux solution

  4. Finally, (assuming the terminal is in the location of the usbreset file) execute this command, you just have to substitute "busnum" and "devnum" with the bus number and device number respectively $sudo ./usbreset /dev/bus/usb/busnum/devnum 

Linux Python solution

The python solution is the same as the "linux solution" but doesn't require compiling the .c executable as it takes advantage of the Python Virtual Machine to execute it at low level.

from fcntl import ioctl;


def resetUsb(busnum,devnum):

    filename = "/dev/bus/usb/{:03d}/{:03d}".format(int(busnum), int(devnum));


    #define USBDEVFS_RESET             _IO('U', 20)

    USBDEVFS_RESET = ord('U') << (4*2) | 20


    fd = open(filename, "wb")

    ioctl(fd, USBDEVFS_RESET, 0)

    fd.close()

Mac solution

To do this in mac you need first to download the reenumerate utility on mac, you can download it here: https://www.dropbox.com/s/rn3wx4qp5no1b6y/reenumerate?dl=1

Once done you need to inspect the usb devices that are on your mac, if you run ioreg -p IOUSB -w0 -l you'll see in the output something like:

+-o AdvanReader-m1-10@14600000  <class AppleUSBDevice, id 0x100000b64, registered, matched, active, busy 0 (0 ms), retain 12>

{

  "sessionID" = 30388838266878

  "idProduct" = 24597

  "iManufacturer" = 1

  "bDeviceClass" = 0

  "bMaxPacketSize0" = 8

  "bcdDevice" = 4096

  "iProduct" = 2

  "iSerialNumber" = 3

  "bNumConfigurations" = 1

  "Bus Power Available" = 250

  "USB Address" = 21

  "Built-In" = No

  "locationID" = 341835776

  "bDeviceSubClass" = 0

  "bcdUSB" = 512

  "USB Product Name" = "AdvanReader-m1-10"

  "PortNum" = 6

  "non-removable" = "no"

  "kUSBSerialNumberString" = "DM53OQOO"

  "bDeviceProtocol" = 0

  "AppleUSBAlternateServiceRegistryID" = 4294970210

  "IOCFPlugInTypes" = {"9dc7b780-9ec0-11d4-a54f-000a27052861"="IOUSBHostFamily.kext/Contents/PlugIns/IOUSBLib.bundle"}

  "IOPowerManagement" = {"DevicePowerState"=0,"CurrentPowerState"=3,"CapabilityFlags"=65536,"MaxPowerState"=4,"DriverPowerState"=3}

  "Device Speed" = 1

  "USB Vendor Name" = "Keonn Technologies"

  "idVendor" = 1027

  "kUSBCurrentConfiguration" = 1

  "IOGeneralInterest" = "IOCommand is not serializable"

  "kUSBProductString" = "AdvanReader-m1-10"

  "USB Serial Number" = "DM53OQOO"

  "kUSBVendorString" = "Keonn Technologies"

  "IOClassNameOverride" = "IOUSBDevice"

}

From it, extract the idVendor and idProduct values, the idVendor should be the same always and then execute ./reenumerate -v <idVendor>,<idProduct>. The output will be like:

Verbose mode ON

Looking for vid: 0x403, pid: 0x6015

Found "AdvanReader-m1-10" @ 0x14600000

Calling USBDeviceReEnumerate

USBDeviceReEnumerate returns 0x00000000