vpelletier / python-dfu

Python implementation of USB DFU device class
GNU General Public License v2.0
25 stars 7 forks source link

can i reset from dfu mode to normal #3

Open premananda8 opened 4 years ago

premananda8 commented 4 years ago

please help me on reset device from dfu mode to normal. i have device object need to reset. i did like this: dfu_device = dfu.DFU(device.open()) dfu_device._reset("Changed to normal")

but i'm getting error as: usb1.USBErrorNotSupported: LIBUSB_ERROR_NOT_SUPPORTED [-12]

vpelletier commented 4 years ago

Hello,

This means libusb_reset_device does not work for some reason. This may depend on what the HCI driver supports (so it may depend on the OS, and possibly on the type of HCI).

As this is a USB-level operation (and not a DFU-level operation), this should be no different from unplugging the device and replugging it: besides receiving bus power, a device get signaled an USB reset condition before being enumerated (added to the USB bus so it can be used by the host), which is what this function also does.

premananda8 commented 4 years ago

thanks for reply. please check this,

with usb1.USBContext() as context:
    for device in context.getDeviceList():
        if (int(0xX) == device.getVendorID() and   (int(0xFFFF) == device.getProductID())):
               print(device)  #Here i'm getting device without serial number
               print(device.getSerialNumber())  #Here i'm getting error as usb1.USBErrorNotSupported: LIBUSB_ERROR_NOT_SUPPORTED [-12] 

anything wrong in my code if not why not getting serial number. please help me i'm unable to proceed further.

vpelletier commented 4 years ago

This would be a libusb error, and not really related to DFU nor this project. The reason for this error may depend on what the OS is, or on what the device firmware is responding (maybe it does not have a serial ?).

You will need to check what is being exchanged with the device. There are free usb capture software tools which should be able to get that for you at least on Windows and GNU/Linux (wireshark).

premananda8 commented 4 years ago

code is not supporting to python version 3.7?

premananda8 commented 4 years ago

STM32 device in dfu mode can i detect serial_number any code is there any library in python present, i am hopeless to proceed, please help.(from this code i need serial number) with usb1.USBContext() as context: for device in context.getDeviceList(): if (int(0xX) == device.getVendorID() and (int(0xFFFF) == device.getProductID())): print(device) #Here i'm getting device without serial number print(device.getSerialNumber()) #Here i'm getting error as usb1.USBErrorNotSupported: LIBUSB_ERROR_NOT_SUPPORTED [-12]