Author Topic: How to disconnect an USB device through dotnet?  (Read 9667 times)

ambreville

  • Member
  • ***
  • Posts: 1
How to disconnect an USB device through dotnet?
« on: August 16, 2010, 02:47:44 am »
Hi,

I have a tricky problem. In my project, we use Panasonic Toughbook CF-19 mobile pc's. These are complemented in the car by a vehicle docking station which supplies power and has a 7" touchscreen and a GPS mouse attached. A while ago, we changed the parameters of the pc so that it went into hibernation while docked. Resuming was only possible outside the dock. On future docks, we started experiencing different kind of crashes according  to the pc submodel. Either a freeze of the pc, hardware memory parity error bluescreen or a windows bluescreen.
We have been looking into it with Microsoft and Panasonic and the result was that the USB-GPS mouse (Haicom 204III-USB) does not  handle hibernation (or standby) correctly. Upgrading drivers etc yielded no result so far.
This gps is a prolific USB-Serial device. Since we are stuck here and it would take a long and costly operation to recall and replace all gps's in the vehicles, I was thinking about sort of ejecting the device by software. Is that possible to eject it through dotnet code? Any pointers or hints?
Another question, did anyone have the same problem with either a Haicom GPS or a Prolific USB-Serial Device?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: How to disconnect an USB device through dotnet?
« Reply #1 on: August 16, 2010, 09:09:52 am »
The DevCon example in the WDK shows how to enable, disable, restart, update, remove and query devices. You would need to call the Windows API functions from the .NET application.

Jan

jcddcjjcd

  • Member
  • ***
  • Posts: 14
Re: How to disconnect an USB device through dotnet?
« Reply #2 on: August 18, 2010, 02:47:24 am »
This may not be what you are looking for but it may help:

// Add handler for .NET power change event.
    SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(this.SystemEvents_PowerModeChanged);

If you wire this up to a handler ie: SystemEvents_PowerModeChanged() then you will know when you are going into suspend etc and when it wakes up again. In my application I just do a Application.Restart() after it resumes and that gets everything going again.

Regards,
John.