locked
How to change USB mode programatically? RRS feed

  • Question

  • Is there a way to change the USB mode programatically using an API, or by changing a registry Key in WM6.5?

    My device has three modes: USB Client, USB Host and USB OTG. I would like to switch betwen USB Host and USB OTG in my application without going through the settings menus becauase the device is in a remote location and user interraction needs to be kept at a minimum.

    Thanks, 

    Wednesday, July 6, 2011 12:05 PM

All replies

  • Why do you want to switch from Host to OTG? if you configure your USB as OTG, it will support both client and host and automatically switch between host and client without user intervention.
    Vinoth.R http://vinoth-vinothblog.blogspot.com http://www.e-consystems.com
    Wednesday, July 6, 2011 12:32 PM
  • Because there is a user application that restricts user access only to the GUI of that application.You can exit the application and gain system acess only if you know the password. If it is on OTG mode then there is a workaround to have access to system files using ActiveSync behind the application security, and that is bad for our company.So when the application starts, it sets the USB in Host mode.IP communication is working and nothing else;ActiveSync is disabled and no one can go behind the system. When you exit the application the USB is set in Client Mode. ActiveSync is working, but IP communication is not. And i cann't get Remote Desktop access if i exit de application.

    Unfortunatelly the original app designer only though about these two USB modes, because when it was designed the old devices did not support OTG.These new ones do, and i thought that i might get a quicker answer here, than hoping to get an answer from them, for which i have to do too much explaining.

    I tryed googling for a solution, but it seems that no one is interested in this option programatically.

    Thursday, July 7, 2011 6:26 AM
  • Why do you want to switch from Host to OTG? if you configure your USB as OTG, it will support both client and host and automatically switch between host and client without user intervention.
    Vinoth.R http://vinoth-vinothblog.blogspot.com http://www.e-consystems.com

    Unfortunately, like a lot of theoretically good ideas, it does not work like this in practice. Some devices only switch to host mode within OTG if certain pins are connected in the relevant USB cable; otherwise it defaults to client. A programmatic solution is much nicer than having to ensure the correct cable is always used. I'm sure you felt like a real champ writing that post, but your vague understanding is not really useful.

    I'm also interested in getting an answer to this. I am told there is a windows function call to switch the mode (Source: Motorola), but it doesn't appear to be in coredll or any of the other smart device libraries on pinvoke. And, like the op said, searching for a solution via google does not yield many appropriate results.

    Edit: Oh, and there is no registry setting for USB mode



    Tuesday, July 26, 2011 10:24 AM
  • I'm also interested in getting an answer to this. I am told there is a windows function call to switch the mode (Source: Motorola), but it doesn't appear to be in coredll or any of the other smart device libraries on pinvoke. And, like the op said, searching for a solution via google does not yield many appropriate results.

    Edit: Oh, and there is no registry setting for USB mode




    Yes tehre is. The original app developers provided 2 executables(USBClient.exe and USBHost.exe) that change the USB mode operation for a Motorola.You simply call that file and the mode changes. They also change other things in the device using a BatchRunner.exe with a *.bat file (just like Windows )to modify registry input wihc is also cool for scripted startup. This is quite a nice approach, but they have no USBOtg.exe file because they havenn't thought about it. Guess i have to ask the developers themselves and a Motorola contact i have. Maybe they know how to get this functionality to WM programatically.
    Thursday, October 13, 2011 8:46 AM
  • Hello Lupusoru,

    Could you please provide some more details here?  I have NOT been able to find these executable's that you mentioned, namely "USBHost.exe" or "USBClient.exe".  I'm working on a WM 6.5 application and I need to be able to alter the USB Mode on the fly.

    Thank you,


    Tuesday, November 26, 2013 5:29 PM