Dear Mark and all,
I have tried with your advices and opened the device properly. But I am facing some problem in issuing IOCTLS through DeviceIoControl. The code snippet is
USB_STRING_DESCRIPTOR *pstrdes=new USB_STRING_DESCRIPTOR();
o.Offset=0;
o.OffsetHigh = 0;
o.hEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
usbscan->NumberOfPipes;
usbscan->PipeInfo;
DWORD junk;
hfile = CreateFile(lpFileName, GENERIC_WRITE|GENERIC_READ, 0, &m_security, OPEN_ALWAYS, (FILE_ATTRIBUTE_NORMAL |FILE_FLAG_OVERLAPPED ), 0);
if (hfile == INVALID_HANDLE_VALUE)
{
// Handle the error.
printf (“CreateFile failed with error %d.\n”, GetLastError());
return (1);
}
else
{
status = DeviceIoControl(hfile, // device to be queried
IOCTL_BSU_GET_STRING_DESCRIPTOR, // operation to perform
NULL, 0, // no input buffer
pstrdes, sizeof(pstrdes), // output buffer
&junk, // # bytes returned
&o); // asynchronous I/O
}
_tprintf(TEXT(“deviceiocontrol error %d\n”,GetLastError()));
CloseHandle(hfile);
The method DeviceIoControl is having problem. I think that I am missing something. The driver source code has some CTL codes and I use one of them in the DeviceIoControl method but no values are returned in the buffer. I tried the method with both Sync and Async operations.
status = DeviceIoControl(hfile,IOCTL_BSU_GET_STRING_DESCRIPTOR,NULL, 0,pstrdes, sizeof(pstrdes),&junk, &o);
In the above method I use the CTL code which is defined in the source code of the driver. When I revealed the source of the driver the above CTL code uses USB_STRING_DESCRIPTOR_TYPE to get the string descriptor. Please advice.
Many thanks in advance.
Regards,
Gajendran
Mark Roddy wrote: The WDK samples include user mode applications that use DeviceIoControl to communicate with a driver. Study those samples and your driver source code.
On Sat, May 24, 2008 at 9:27 AM, Gajendran Gajendran wrote:
Dear Mark,
Thank you so much for your prompt and kind reply.
I use the first method to open the device and I got the HANDLE correctly. But I don’t know how to give the IOCTL’s to the device. In the driver source code there are certain IOCTL’s which I have studied. Please guide me how to give the control codes. Also I tried using the DeviceIoControl but I am doing some mistakes. That is I dont know how to implement in the code. Please advice.
Many thanks.
Kind Regards,
Gajendran
Mark Roddy wrote:
If this is a proprietary interface (not a standard HID for example) then the driver has to create symbolic links visible to user mode applications for its device objects that represent its USB endpoints. There are two mechanisms the driver could use to do this:
the driver could use IoCreateSymbolicLink - and would provide an explicit name for the link.
the driver could use IoRegisterDeviceInterface - and would provide an Interface GUID for the symbolic links.
In the first case you use the symbolic link name to open the device using the standard PlatfomSDK CreateFile API.
In the second case you use the Interface GUID to find the symbolic link names by calling the appropriate SetupDi APIs in the PlatformSDK, and then you call CreateFile.
Once you have a handle to your driver’s device object, communciation generally is done through the use of custom IOCTLs. Your driver source code again will be the guide to what those IOCTLs are and how they are used.
On Sat, May 24, 2008 at 7:50 AM, Gajendran Gajendran wrote:
Dear All,
I am having a USB device with 1 Control Point and 3 BulkPoints. I too have the source code for the driver developed by the vendor. Now I need to get the data from the device using VC++ at user level.
Please guide me or tell me how to proceed, in order to get data from the device. Is there any System calls or Windows API to be used ? Please advice and give me the steps to proceed.
Many thanks in advance.
Best Regards,
Gajendran
— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
–
Mark Roddy — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
–
Mark Roddy — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer