From: Uwe Sieber on
shiva wrote:
> hi Sten,
> I am sure about the data i am asking for :)...
>
> I am using DeviceIoControl() function after createfile().\
> i am querying for USB_DEVICE_DESCRPTOR but always deviceIoControl
> giving me "Invalid function" as error.

And the IOCTL code you are using is still a big secret?

I suspect you have used IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION
as shown in the USBview sample I had pointed you on before. And which
you havn't said thanks for btw, which would be good idea to keep the
helpers happy.

What you are obviously doing is trial and error programming.

The USBview sample uses a handle to an USB HUB device. A different
type of handle will not work.


Uwe

From: shiva on
This is my code snippet, here my DeviceIoControl throwing me "Invalid
Function" error.

g_szDevicePath value is
\\?\USB#Vid_413c&Pid_4011#0e01312e-0507-1116-2800-0050bfe45ce5#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
i already posted, how i am getting this value.

I am getting handle properly, but DeviceIoControl is failing..
Am i wrong with IOCTL_ Control word, or any mistake in
UsbscanGetDescriptor values?

Is there mistake in my approach it self..... pls lemme know!

ShowErrorMessage() is own function which display the corresponding
error message for value returned by GetLastError();

I feel, i given sufficient info, can we solve this.

USBSCAN_GET_DESCRIPTOR UsbscanGetDescriptor = { 0 };
USB_DEVICE_DESCRIPTOR UsbDeviceDescriptor = { 0 };

HANDLE hUsbDevice = CreateFile ( g_szDevPath,\
GENERIC_READ | GENERIC_WRITE,\
0,\
NULL,\
OPEN_EXISTING,\
0,\
NULL );

if ( INVALID_HANDLE_VALUE == hUsbDevice )
{
dwError = GetLastError ();
ShowErrorMessage ( NULL, &dwError );
MessageBox ( NULL, "Not able to create handle to USB device", "Sorry",
MB_OK );
break;
}


dwSize = sizeof ( UsbDeviceDescriptor );
UsbscanGetDescriptor.DescriptorType = USB_DEVICE_DESCRIPTOR_TYPE;
UsbscanGetDescriptor.Index = 1;
UsbscanGetDescriptor.LanguageId = 0;

dwError = ( DWORD ) DeviceIoControl ( hUsbDevice, \
IOCTL_GET_USB_DESCRIPTOR , \
&UsbscanGetDescriptor, \
sizeof ( UsbscanGetDescriptor ), \
&UsbDeviceDescriptor, \
dwSize, \
&dwInDataSize, \
NULL );
if ( 0 == dwError )
{
dwError = GetLastError ( );
ShowErrorMessage ( NULL, &dwError );
break;
}


Uwe Sieber wrote:
> shiva wrote:
> > hi Sten,
> > I am sure about the data i am asking for :)...
> >
> > I am using DeviceIoControl() function after createfile().\
> > i am querying for USB_DEVICE_DESCRPTOR but always deviceIoControl
> > giving me "Invalid function" as error.
>
> And the IOCTL code you are using is still a big secret?
>
> I suspect you have used IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION
> as shown in the USBview sample I had pointed you on before. And which
> you havn't said thanks for btw, which would be good idea to keep the
> helpers happy.
>
> What you are obviously doing is trial and error programming.
>
> The USBview sample uses a handle to an USB HUB device. A different
> type of handle will not work.
>
>
> Uwe

From: Uwe Sieber on

IOCTL_GET_USB_DESCRIPTOR is documented to work with still
image devices. Is your device of this type?

Uwe



shiva wrote:
> This is my code snippet, here my DeviceIoControl throwing me "Invalid
> Function" error.
>
> g_szDevicePath value is
> \\?\USB#Vid_413c&Pid_4011#0e01312e-0507-1116-2800-0050bfe45ce5#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
> i already posted, how i am getting this value.
>
> I am getting handle properly, but DeviceIoControl is failing..
> Am i wrong with IOCTL_ Control word, or any mistake in
> UsbscanGetDescriptor values?
>
> Is there mistake in my approach it self..... pls lemme know!
>
> ShowErrorMessage() is own function which display the corresponding
> error message for value returned by GetLastError();
>
> I feel, i given sufficient info, can we solve this.
>
> USBSCAN_GET_DESCRIPTOR UsbscanGetDescriptor = { 0 };
> USB_DEVICE_DESCRIPTOR UsbDeviceDescriptor = { 0 };
>
> HANDLE hUsbDevice = CreateFile ( g_szDevPath,\
> GENERIC_READ | GENERIC_WRITE,\
> 0,\
> NULL,\
> OPEN_EXISTING,\
> 0,\
> NULL );
>
> if ( INVALID_HANDLE_VALUE == hUsbDevice )
> {
> dwError = GetLastError ();
> ShowErrorMessage ( NULL, &dwError );
> MessageBox ( NULL, "Not able to create handle to USB device", "Sorry",
> MB_OK );
> break;
> }
>
>
> dwSize = sizeof ( UsbDeviceDescriptor );
> UsbscanGetDescriptor.DescriptorType = USB_DEVICE_DESCRIPTOR_TYPE;
> UsbscanGetDescriptor.Index = 1;
> UsbscanGetDescriptor.LanguageId = 0;
>
> dwError = ( DWORD ) DeviceIoControl ( hUsbDevice, \
> IOCTL_GET_USB_DESCRIPTOR , \
> &UsbscanGetDescriptor, \
> sizeof ( UsbscanGetDescriptor ), \
> &UsbDeviceDescriptor, \
> dwSize, \
> &dwInDataSize, \
> NULL );
> if ( 0 == dwError )
> {
> dwError = GetLastError ( );
> ShowErrorMessage ( NULL, &dwError );
> break;
> }
>
>
> Uwe Sieber wrote:
>> shiva wrote:
>>> hi Sten,
>>> I am sure about the data i am asking for :)...
>>>
>>> I am using DeviceIoControl() function after createfile().\
>>> i am querying for USB_DEVICE_DESCRPTOR but always deviceIoControl
>>> giving me "Invalid function" as error.
>> And the IOCTL code you are using is still a big secret?
>>
>> I suspect you have used IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION
>> as shown in the USBview sample I had pointed you on before. And which
>> you havn't said thanks for btw, which would be good idea to keep the
>> helpers happy.
>>
>> What you are obviously doing is trial and error programming.
>>
>> The USBview sample uses a handle to an USB HUB device. A different
>> type of handle will not work.
>>
>>
>> Uwe
>
From: shiva on
Thanks Uwe,

My device is not still image device.
So, may i know which IOCTL code word i can use with same HANDLE to
retrieve device descriptor. Is it possible like this.

Shiva



Uwe Sieber wrote:
> IOCTL_GET_USB_DESCRIPTOR is documented to work with still
> image devices. Is your device of this type?
>
> Uwe
>
>
>
> shiva wrote:
> > This is my code snippet, here my DeviceIoControl throwing me "Invalid
> > Function" error.
> >
> > g_szDevicePath value is
> > \\?\USB#Vid_413c&Pid_4011#0e01312e-0507-1116-2800-0050bfe45ce5#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
> > i already posted, how i am getting this value.
> >
> > I am getting handle properly, but DeviceIoControl is failing..
> > Am i wrong with IOCTL_ Control word, or any mistake in
> > UsbscanGetDescriptor values?
> >
> > Is there mistake in my approach it self..... pls lemme know!
> >
> > ShowErrorMessage() is own function which display the corresponding
> > error message for value returned by GetLastError();
> >
> > I feel, i given sufficient info, can we solve this.
> >
> > USBSCAN_GET_DESCRIPTOR UsbscanGetDescriptor = { 0 };
> > USB_DEVICE_DESCRIPTOR UsbDeviceDescriptor = { 0 };
> >
> > HANDLE hUsbDevice = CreateFile ( g_szDevPath,\
> > GENERIC_READ | GENERIC_WRITE,\
> > 0,\
> > NULL,\
> > OPEN_EXISTING,\
> > 0,\
> > NULL );
> >
> > if ( INVALID_HANDLE_VALUE == hUsbDevice )
> > {
> > dwError = GetLastError ();
> > ShowErrorMessage ( NULL, &dwError );
> > MessageBox ( NULL, "Not able to create handle to USB device", "Sorry",
> > MB_OK );
> > break;
> > }
> >
> >
> > dwSize = sizeof ( UsbDeviceDescriptor );
> > UsbscanGetDescriptor.DescriptorType = USB_DEVICE_DESCRIPTOR_TYPE;
> > UsbscanGetDescriptor.Index = 1;
> > UsbscanGetDescriptor.LanguageId = 0;
> >
> > dwError = ( DWORD ) DeviceIoControl ( hUsbDevice, \
> > IOCTL_GET_USB_DESCRIPTOR , \
> > &UsbscanGetDescriptor, \
> > sizeof ( UsbscanGetDescriptor ), \
> > &UsbDeviceDescriptor, \
> > dwSize, \
> > &dwInDataSize, \
> > NULL );
> > if ( 0 == dwError )
> > {
> > dwError = GetLastError ( );
> > ShowErrorMessage ( NULL, &dwError );
> > break;
> > }
> >
> >
> > Uwe Sieber wrote:
> >> shiva wrote:
> >>> hi Sten,
> >>> I am sure about the data i am asking for :)...
> >>>
> >>> I am using DeviceIoControl() function after createfile().\
> >>> i am querying for USB_DEVICE_DESCRPTOR but always deviceIoControl
> >>> giving me "Invalid function" as error.
> >> And the IOCTL code you are using is still a big secret?
> >>
> >> I suspect you have used IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION
> >> as shown in the USBview sample I had pointed you on before. And which
> >> you havn't said thanks for btw, which would be good idea to keep the
> >> helpers happy.
> >>
> >> What you are obviously doing is trial and error programming.
> >>
> >> The USBview sample uses a handle to an USB HUB device. A different
> >> type of handle will not work.
> >>
> >>
> >> Uwe
> >

From: Uwe Sieber on

The only way I know is as shown in the USBview and DisplayUSB
samples: Enumerate the whole USB tree until you find your device.

Uwe



shiva wrote:
> Thanks Uwe,
>
> My device is not still image device.
> So, may i know which IOCTL code word i can use with same HANDLE to
> retrieve device descriptor. Is it possible like this.
>
> Shiva
>
>
>
> Uwe Sieber wrote:
>> IOCTL_GET_USB_DESCRIPTOR is documented to work with still
>> image devices. Is your device of this type?
>>
>> Uwe
>>
>>
>>
>> shiva wrote:
>>> This is my code snippet, here my DeviceIoControl throwing me "Invalid
>>> Function" error.
>>>
>>> g_szDevicePath value is
>>> \\?\USB#Vid_413c&Pid_4011#0e01312e-0507-1116-2800-0050bfe45ce5#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
>>> i already posted, how i am getting this value.
>>>
>>> I am getting handle properly, but DeviceIoControl is failing..
>>> Am i wrong with IOCTL_ Control word, or any mistake in
>>> UsbscanGetDescriptor values?
>>>
>>> Is there mistake in my approach it self..... pls lemme know!
>>>
>>> ShowErrorMessage() is own function which display the corresponding
>>> error message for value returned by GetLastError();
>>>
>>> I feel, i given sufficient info, can we solve this.
>>>
>>> USBSCAN_GET_DESCRIPTOR UsbscanGetDescriptor = { 0 };
>>> USB_DEVICE_DESCRIPTOR UsbDeviceDescriptor = { 0 };
>>>
>>> HANDLE hUsbDevice = CreateFile ( g_szDevPath,\
>>> GENERIC_READ | GENERIC_WRITE,\
>>> 0,\
>>> NULL,\
>>> OPEN_EXISTING,\
>>> 0,\
>>> NULL );
>>>
>>> if ( INVALID_HANDLE_VALUE == hUsbDevice )
>>> {
>>> dwError = GetLastError ();
>>> ShowErrorMessage ( NULL, &dwError );
>>> MessageBox ( NULL, "Not able to create handle to USB device", "Sorry",
>>> MB_OK );
>>> break;
>>> }
>>>
>>>
>>> dwSize = sizeof ( UsbDeviceDescriptor );
>>> UsbscanGetDescriptor.DescriptorType = USB_DEVICE_DESCRIPTOR_TYPE;
>>> UsbscanGetDescriptor.Index = 1;
>>> UsbscanGetDescriptor.LanguageId = 0;
>>>
>>> dwError = ( DWORD ) DeviceIoControl ( hUsbDevice, \
>>> IOCTL_GET_USB_DESCRIPTOR , \
>>> &UsbscanGetDescriptor, \
>>> sizeof ( UsbscanGetDescriptor ), \
>>> &UsbDeviceDescriptor, \
>>> dwSize, \
>>> &dwInDataSize, \
>>> NULL );
>>> if ( 0 == dwError )
>>> {
>>> dwError = GetLastError ( );
>>> ShowErrorMessage ( NULL, &dwError );
>>> break;
>>> }
>>>
>>>
>>> Uwe Sieber wrote:
>>>> shiva wrote:
>>>>> hi Sten,
>>>>> I am sure about the data i am asking for :)...
>>>>>
>>>>> I am using DeviceIoControl() function after createfile().\
>>>>> i am querying for USB_DEVICE_DESCRPTOR but always deviceIoControl
>>>>> giving me "Invalid function" as error.
>>>> And the IOCTL code you are using is still a big secret?
>>>>
>>>> I suspect you have used IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION
>>>> as shown in the USBview sample I had pointed you on before. And which
>>>> you havn't said thanks for btw, which would be good idea to keep the
>>>> helpers happy.
>>>>
>>>> What you are obviously doing is trial and error programming.
>>>>
>>>> The USBview sample uses a handle to an USB HUB device. A different
>>>> type of handle will not work.
>>>>
>>>>
>>>> Uwe
>