I need to simulate plug/unplug for USB device in C++ under Windows environment. I know the existence of this IOCTL
http://msdn.microsoft.com/en-us/library/windows/hardware/ff537243(v=vs.85).aspx
(IOCTL_INTERNAL_USB_CYCLE_PORT) which indeed is what I am looking for, but I don't know how to use.
Is there anyone which can tell me who I can find an example or share some lines of code in order to help me, please!
Thanks in advance.
Since you are in User Mode land and using C++ I'd recommend looking at the devcon sample. Out of the box you can use it on the command line to issue PnP or disable/enable requests to devices. The source code is also available, so you can use that as a start to get this functionality added to your environment.
Related
iam trying to develop a tool which runs as daemon process in windows and it always tracks the usb insertion.i.e if a new usb is inserted it verifies the usb and allows the user to access,and if it is not an valid usb ,it simply don't allow the user to access it.
I have gone through all the search results i made on google but i was not able to follow,can you guys please tell ,from where should i start and even i went through MSDN .
I want to develop the tool in C++.Please help me with your suggestion and links for developing.Thank you in advance.
This information on www.codeproject.com may help your question , but it is in C# language . If you understand the steps in this example , you'll find it easy.
Detecting usb devices in windows using c#
If you know about mono framework you'll be able to port this project to run on linux environment.
I am developing C++/Qt application which interacts with Tektronix TDS2002 oscilloscope via USB. The oscilloscope appears as "USB Test and Measurement device (IVI)".
Currently I use TekVISA library supplied by the oscilloscope's vendor. It works, but it is huge, old, buggy and poorly maintained. Therefore I would like to bypass the library and interface the device directly.
So far I have found this simple library: https://github.com/xyphro/WinUsbTmc It is exactly what I am looking for, but it uses libusb which requires to install some device filter and in addition it is advised to be more development tool than customer solution. Do you have any experience on this?
What is the easiest way to interact with USB Test and Measurement device in Windows/C++/Qt?
Thank you for your suggestions :)
You need a USB driver. My oscilloscope works with the driver included in this VISA package (the driver can be extracted very easily): http://www.keysight.com/main/software.jspx?cc=CZ&lc=eng&nid=-11143.0.00&id=2504667&pageMode=CV I assume all USB TMC devices can use the same driver, but I have no possibility to check this.
USB driver can be accessed via standard Windows functions. Guys on this forum were really close:
https://forum.tek.com/viewtopic.php?f=568&t=137573 and also this document was very useful: http://www.ivifoundation.org/downloads/Class%20Specifications/Ivi-6%202_USBTMC_2010-03-23.doc
You cannot write commands to OSC directly - data you send and receive have certain header which has to be in the correct format, otherwise the oscilloscope ignores the message. See reading and writting implementation in this simple library: https://github.com/xyphro/WinUsbTmc I didn't use this library because it uses libusb library which uses some kind of device filter and I personally do not like this concept (and in addition I have genuine working driver).
Data you read have also a simple header. To ensure you fit the header structure on input data well, you should first flush the input buffer. Then you issue reading request (using write command - see WinUsbTmc library above) and finally you receive the data and fit the header on its beginning.
I hope this will help to somebody :)
With regards
klasyc
I'm trying to write an application that will take specific action when it detects an overcurrent condition on any USB port.
However, my googlefu is not able to come up with anything useful (though I can now tell you 101 ways to fix a USB overcurrent problem).
Is there are standard windows API to retrieve USB status info?
If not is there another/better way to detect USB overcurrent conditions programatically?
As far as I can see here http://msdn.microsoft.com/en-us/library/ff539687 you need to turn to the WDK (Window Driver Kit).
I'm currently building a c++ program (with Qt) to take picture from a camera device. This part is actualy done, now I need to control 8 flashs divided in two groups in an automatic way.
The flash I already use are from ELINCHROM http://www.elinchrom.com/ and this device seems to be perfect for what I need but I could not find anywhere a way to control it from a different application than the one elinchrom propose.
Do you know if what I intend to do is even possible? If a solution exist with another brand I will also take it.
Thank you in advance for any replies, and please excuse my english.
Should be possible; the driver guide states that the driver is really a USB serial port driver. That means you can probably reverse-engineer the protocol.
I try to send/read a control message with a specific setup packet to an USB device.
I've found at MSDN this documentation: http://msdn.microsoft.com/en-us/library/ff537344%28v=vs.85%29.aspx and at the usbuser.h the struct "_USB_SEND_RAW_COMMAND_PARAMETERS" which can be filled with the parameters for a setup packet. The problem ist that MSDN says about this function: "Do not use this request".
The next try was the request code "USBUSER_PASS_THRU" but I don't know what the parameters mean and I don't think that it is possible to send a specific setup packet with this request code.
I can't use WinUSB because I would like to solve this without any installation or other requirements to the target PC.
Has anybode solved this problem or has an hint to solve this?
Thank a lot.
Regards
If you want to avoid driver installations, you could make your device emulate an Human Interface Device (HID) or Mass Storage Device; both of those types of devices work automatically with the built-in Microsoft drivers.
If you figure out another way to do it, I'd be interested to hear the answer.