Author Topic: Windows Python access usbdevice.py  (Read 36331 times)

mpflaga

  • Newbie
  • *
  • Posts: 3
Windows Python access usbdevice.py
« on: January 29, 2013, 12:45:02 pm »
I have found that “Digispark - Example Programs” being all python based need the additional step detailed below, as to allow the python based windows executable access to the USB devices. If this step is not done the DigiRGB.exe and other example exe’s fault at __init__  for the usbdevice.py as they can only see allowed “filtered” devices on window systems. I don't see this clearly denoted anywhere, causing much grief. Resulting in the below error messages.

Traceback (most recent call last):
  File "<string>", line 29, in <module>
  File "C:\projects\Arduino 1.03 Digispark\Digispark - Example Programs\DigiBlink\windows\arduino\usbdevice.py", line 58, in __init__
    raise Exception("Device not found")
Exception: Device not found


Some digging and help from others lead me to the following solution:

Install a device filter using install-filter-win.exe for vid:16c0 pid:05df USB Human Interface Device, which is the VID/PID for the DigiSpark, after it boots. Simply cancel out of it, after the filter is added. (it will auto repeat) You can use usbview to determine it is correctly there, prior. install-filter-win.exe can be found within and downloaded from “libusb-win32-bin-1.2.6.0


I understand that this aspect is not directly related to the DigiSpark product, hence it was not included nor discussed. However, it is necessary for the provided examples to properly work. As to have a joyful experience.
It may be possible that I am missing such guidance. But if it exists it does not appear readily. Even when digging.
I recommend that the examples readme's include instructions about the need for the provided EXE examples requiring the added python filters. Along with including the install-filter-win.exe in the IDE's example directories.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Windows Python access usbdevice.py
« Reply #1 on: January 29, 2013, 06:09:06 pm »
I've never run into this on our test machines (some of which were clean installs) - but I have no doubt it is an issue for some - and might have to do with permissions levels in Windows.


I will add a link to this post in the trouble shooting section as a start - and update the readmes next release.


Thanks!

mpflaga

  • Newbie
  • *
  • Posts: 3
Re: Windows Python access usbdevice.py
« Reply #2 on: January 29, 2013, 10:10:12 pm »
Note that my machine was using admin permission and is WinXP (doubt that would make much of a diff). As the failure was in the return of zero by the usb object from the library, from the usbdevice.py. And the machine does not have any Python installed.


Not sure if there was a particular INF file to install that would have avoided the need for install-filter-win.exe
I looks like inf-wizard.exe can make custom INF's. but looks like they still need to be registered with install-filter-win.exe. So that libusb-1.0.dll may access them.


Regardless, I got that demo working.


Have fun.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Windows Python access usbdevice.py
« Reply #3 on: January 29, 2013, 10:20:44 pm »
Thanks for the additional details - just to double check did you install the DigiUSB driver (not the main Digispark driver) in the "Digispark - Example Programs\DigiUSB\windows driver" folder?

mpflaga

  • Newbie
  • *
  • Posts: 3
Re: Windows Python access usbdevice.py
« Reply #4 on: January 30, 2013, 09:24:01 am »

That did it.
I removed the filter, ensured the DigiRBG.exe failed as expected.
Then ran the ..\Arduino 1.03 Digispark\Digispark - Example Programs\DigiUSB\windows driver\InstallDriver.exe, seeing it successfully installed the DigiUSB.inf
Then the DigiRBG.exe now works, along with monitor.exe. This makes sense as I see that libusb has a inf-wizard.exe, which is what you must have used to create DigiUSB.inf. I thought I read somewhere that no additional drivers are needed and noted that I saw the DigiSpark show up as a normal HID. Thinking it would work. I suspect this is the case for other applications that can access that HID directly. Whereas either the filter or DigiUSB.inf allows access to the LibUSB used by the python examples.


So I must have missed the instruction somewhere to install the DigiUSB driver (not to be confused with the boot loader driver).


Not being fluent in the supporting documents of this yet. I find the following, related to this subject:
..\Arduino 1.03 Digispark\Digispark - Example Programs\DigiUSB\readme.txt
..\Arduino 1.03 Digispark\Digispark - Example Programs\Digispark-Cheerlights\readme.txt
Both have the vague statement "Windows users should install the windows driver first."


and
..\Arduino 1.03 Digispark\Digispark - Example Programs\DigiBlink\DigiRGB Readme.txt
..\Arduino 1.03 Digispark\Digispark - Example Programs\DigiBlink\DigiRGBMail Readme.txt


do not reference it, at all.


I would recommend elaborating in each of the corresponding readme's and tutorials as to which driver is needed for windows. As it is easily miss interpreted as the Digispark_Bootloader.inf and not the needed DigiUSB.inf. Along with not being mentioned for those who start off with DigiRBG first and then work up to DigiUSB, as opposed to the reverse order.


Have Fun.

emcniece

  • Newbie
  • *
  • Posts: 23
  • Seriously guys... I have too many hobbies. <3 DS
Re: Windows Python access usbdevice.py
« Reply #5 on: March 01, 2013, 02:37:56 pm »
I'm running into this as well - Win7 SP1 x64. I encountered the __init__ error at first, then after reading around found this and followed the instructions... thank you x1000 for posting those here.


So far I have run the "Example Programs\DigiUSB\windows driver\InstallDriver.exe" program as well as the libusb install-filter-win.exe program. The filter installer claimed to have installed the filter properly and I can confirm that the device shows in the USB View program, but when re-running the install-filter-win.exe and going into "Remove a device filter", no filters show up.


Now I'm hitting a different error:


Code: [Select]
Found: 0x16c0 0x05df DigiUSB digistump.com
Traceback (most recent call last):
  File "<string>", line 51, in <module>
IndexError: list index out of range




Any thoughts as to what this means?

emcniece

  • Newbie
  • *
  • Posts: 23
  • Seriously guys... I have too many hobbies. <3 DS
Re: Windows Python access usbdevice.py
« Reply #6 on: March 01, 2013, 02:48:55 pm »
To clarify, this error is appearing when running DigiRGB.exe. A different error appears when running DigiRGBMail.exe:


Code: [Select]
Traceback (most recent call last):
  File "<string>", line 7, in <module>
IndexError: list index out of range

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Windows Python access usbdevice.py
« Reply #7 on: March 01, 2013, 07:31:16 pm »

DigiRGB expects to be started with arguments - three to be specific each a integer 0-255 to specify what each color should be


ie>  DigiRGB 255 255 255   - for white and DigiRGB 255 0 0   - for red


DigiRGBMail expects one argument - the username portion of the mailiantor address it should check


I think the readme in the folder they are in details this - but it might not