Author Topic: USB device change no longer works  (Read 16555 times)

theoracle39

  • Member
  • ***
  • Posts: 8
USB device change no longer works
« on: July 08, 2010, 03:42:42 pm »
I've been editing the USB HID code for VB.net to work with a PIC 4550 micro and got things mostly working, but I have a few problems.

1.  One feature that I want is for the device to be detected automatically when I plug it in (even after the program is running) rather than having to click the Find My Device button.  I tried to put Findthehid() into the OnDeviceChange sub, but I found that m.WParam.ToInt32 = 7 and DBT_DEVICEARRIVAL = 32768 so the program thinks no device has been attached.

2.  The second problem is related to the first.  If I plug the device in before I start the program then everything runs fine.  When I unplug the device, I get an unexpected exception in module Hid, method DangerousAddRef.  The exception is Safe handle has been closed.

Any suggestions on how to track down the cause of these problems would be appreciated.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB device change no longer works
« Reply #1 on: July 08, 2010, 08:48:03 pm »
Are you using the most recent version of my code from:

www.Lvr.com/hidpage.htm

Jan Axelson
www.Lvr.com

theoracle39

  • Member
  • ***
  • Posts: 8
Re: USB device change no longer works
« Reply #2 on: July 08, 2010, 09:19:21 pm »
Yes, I am using the most recent code from the HID section of your website.

theoracle39

  • Member
  • ***
  • Posts: 8
Re: USB device change no longer works
« Reply #3 on: July 09, 2010, 10:32:50 am »
I did some more investigating and it turns out that even if I run the original code I can make the exception happen by clicking the Continuous button and sending data that doesn't correspond to any commands that the device recognizes.  I can also make it sometimes happen by clicking the Continuous button and unplugging the USB cable.  I was also able to get the program to detect the device automatically when I plug it in so my only problem is this exception.
« Last Edit: July 09, 2010, 11:05:55 am by theoracle39 »

sponge7

  • Member
  • ***
  • Posts: 1
Re: USB device change no longer works
« Reply #4 on: September 15, 2010, 03:26:38 pm »
Hello,

I have been seeing the same issue (sometimes the program will get into this bad state) and the only way I can fix it is to do a hard power cycle (turn off system and turn on system).

Have you guys made any progress on this issue by any chance? :)