From: Mario on
I am using DeviceIoControl to send a command to a USB device. The device
answers back with some data. The problem is when I send the command to a
device that doesn't support the command sent by DeviceIoControl, the program
hangs on the DeviceIoControl and I have to reboot the PC to recover. I tried
to use Overlapped with DeviceIoControl by with no success.
--
Mario
From: Gianluca Varenni on
Where does it hang exactly?

Are you developing the driver for this USB device?
In this case, the first thing I would do is attaching a debugger to the
driver and see exactly where it hangs (it probably hangs sending the URB
down in the USB stack, I would bet).

Using overlapped I/O doesn't help at all. It just means that your
DeviceIoControl returns immediately and the driver serving that request will
complete the request concurrently in parallel with your application. From
the driver point of view, using Overlapped I/O or not doesn't make any
difference, as a driver treats all the requests as overlapped (i.e. it can
complete them synchronously or asynchronously).

Hope it helps
GV

--
Gianluca Varenni, Windows DDK MVP

CACE Technologies
http://www.cacetech.com


"Mario" <Mario(a)discussions.microsoft.com> wrote in message
news:3F0AD71B-D51E-451A-9783-914D2073CCF7(a)microsoft.com...
>I am using DeviceIoControl to send a command to a USB device. The device
> answers back with some data. The problem is when I send the command to a
> device that doesn't support the command sent by DeviceIoControl, the
> program
> hangs on the DeviceIoControl and I have to reboot the PC to recover. I
> tried
> to use Overlapped with DeviceIoControl by with no success.
> --
> Mario


From: chris.aseltine on
On Apr 24, 3:46 pm, Mario <Ma...(a)discussions.microsoft.com> wrote:

> I am using DeviceIoControl to send a command to a USB device. The device
> answers back with some data. The problem is when I send the command to a
> device that doesn't support the command sent by DeviceIoControl, the program
> hangs on the DeviceIoControl and I have to reboot the PC to recover. I tried
> to use Overlapped with DeviceIoControl by with no success.

If your device doesn't support a certain control request, I believe
the proper behavior is to respond with "STALL". For an unsupported
bulk request ... well, I guess it could consume the data and throw it
away, or NAK indefinitely.

In either case, you should be able to recover by calling CancelIo().
If you have to reboot, there's a bug in the driver and you're losing
IRPs somewhere.
From: Tim Roberts on
Mario <Mario(a)discussions.microsoft.com> wrote:
>
>I am using DeviceIoControl to send a command to a USB device. The device
>answers back with some data. The problem is when I send the command to a
>device that doesn't support the command sent by DeviceIoControl, the program
>hangs on the DeviceIoControl and I have to reboot the PC to recover.

How is it that you found yourself in a circumstance where you are sending
an ioctl to a device that isn't yours?
--
Tim Roberts, timr(a)probo.com
Providenza & Boekelheide, Inc.
From: chris.aseltine on
On Apr 26, 12:45 am, Tim Roberts <t...(a)probo.com> wrote:

> Mario <Ma...(a)discussions.microsoft.com> wrote:
>
>> I am using DeviceIoControl to send a command to a USB device. The device
>> answers back with some data. The problem is when I send the command to a
>> device that doesn't support the command sent by DeviceIoControl, the program
>> hangs on the DeviceIoControl and I have to reboot the PC to recover.
>
> How is it that you found yourself in a circumstance where you are sending
> an ioctl to a device that isn't yours?

He didn't say the device wasn't his. He just said the device doesn't
support the "command" sent by DeviceIoControl() (without saying what
that 'command' is, natch.) That doesn't mean it's not his device.