How to use DeviceIoControl to access an external USB device from MFC
-
Hello, from a MFC program I need to send data to an external USB Device. System: Windows XP SP3, MS Visual Studio 2008, WinDDK (most current). Because I don't have any valid documentation I used a sniffer showing me the used commands. GET_DESCRIPTOR_FROM_DEVICE and BULD_OR_INTERRUPT_TRANSFER Using CreateFile I can successfull connect to the device. But I failed to use DeviceIoControl.
HANDLE result = CreateFile(dev_name, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
USBSCAN_GET_DESCRIPTOR data1;
DWORD bytesReturned;
BOOL b = DeviceIoControl(handle, IOCTL_GET_USB_DESCRIPTOR, NULL, 0, &data1, sizeof(USBSCAN_GET_DESCRIPTOR), &bytesReturned, NULL);Error C2065 "USBSCAN_GET_DESCRIPTOR" After including "usbscan.h" I get C2065 on METHOD_BUFFERED and FILE_ANY_ACCESS and C3861 on CTL_CODE. When including wdm.h I get about 107 errors in driverspecs.h and kernelspecs.h. So please, can anybody help me to get this run. Thanks Stefan
-
Hello, from a MFC program I need to send data to an external USB Device. System: Windows XP SP3, MS Visual Studio 2008, WinDDK (most current). Because I don't have any valid documentation I used a sniffer showing me the used commands. GET_DESCRIPTOR_FROM_DEVICE and BULD_OR_INTERRUPT_TRANSFER Using CreateFile I can successfull connect to the device. But I failed to use DeviceIoControl.
HANDLE result = CreateFile(dev_name, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
USBSCAN_GET_DESCRIPTOR data1;
DWORD bytesReturned;
BOOL b = DeviceIoControl(handle, IOCTL_GET_USB_DESCRIPTOR, NULL, 0, &data1, sizeof(USBSCAN_GET_DESCRIPTOR), &bytesReturned, NULL);Error C2065 "USBSCAN_GET_DESCRIPTOR" After including "usbscan.h" I get C2065 on METHOD_BUFFERED and FILE_ANY_ACCESS and C3861 on CTL_CODE. When including wdm.h I get about 107 errors in driverspecs.h and kernelspecs.h. So please, can anybody help me to get this run. Thanks Stefan
What is the USB device? It could be a USB com port, a USB network card for example. If so use the usual API to access it. COM API or sockets. Dont forget USB is just the protocol between the system and the hardware, at the app level it really is irrelevant.
============================== Nothing to say.
-
What is the USB device? It could be a USB com port, a USB network card for example. If so use the usual API to access it. COM API or sockets. Dont forget USB is just the protocol between the system and the hardware, at the app level it really is irrelevant.
============================== Nothing to say.
Hello, its a medical device having leds. I have the commandsets to enable or disable them. But I cannot send any commands. Stefan
-
Hello, its a medical device having leds. I have the commandsets to enable or disable them. But I cannot send any commands. Stefan
-
How does the system see the device? ie, in DeviceManager.
============================== Nothing to say.
Hello, it shows under "custom usb devices" as "[Company Name] Familiy Device". Stefan
-
Hello, it shows under "custom usb devices" as "[Company Name] Familiy Device". Stefan
Hmm, so its not presenting itself as a well known device then. What sort of driver is sitting on the device? (ie what are the names) Is there an inf file with a custom driver for example? If so you will need documentation on the interface to that driver. The mnuf should be able to provide it.
============================== Nothing to say.
-
Hmm, so its not presenting itself as a well known device then. What sort of driver is sitting on the device? (ie what are the names) Is there an inf file with a custom driver for example? If so you will need documentation on the interface to that driver. The mnuf should be able to provide it.
============================== Nothing to say.
-
I'm thinking it would be a wee more efficient if
winioctl.h
andusbscan.h
were added to the project'sstdafx.h
file."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous