Main Site Documentation

Explanation of USBClientController.State


#1

I’m wondering if we can get a more verbose explanation of what the various states enumerated as USBClientController.State.

Detached 3 USB port state.
Attached 1 USB port state.
Powered 2 USB port state.
Default 3 USB port state.
Address 4 USB port state.
Running 5 USB port state.
Suspended 6 USB port state.
Stopped 255 USB port state.

In one of the examples ‘Running’ is used to discover when the client is connected to the host. I would assume that that ‘Attached’ would be the state after .AttachLun is called. I’m sure the info is out on the interweb somewhere but I have been unable to locate it yet.


#2

These are various states when communicating with USB device initially…
You do not need to worry about them. If it is in running state then it is connected and communicating with PC otherwise assume it is not connected to PC.


#3

I was hoping there was an easy way to know if the device was in the attached and enabled state. I just did a quick test and see it goes directly from ‘Suspended’ to ‘Running’ after AttachLun and EnableLun are called. If the USB cable is pulled then it goes back to ‘Suspended’.

‘Running’ simply means the USB connection has been established. It does not infer that that MassStorage object has been attached or enabled, nor is there a way to discover if that is the case. It seems like the only way to do it is for the developer to keep track of the state that place the MassStorage object in since you can’t poll it to find its current state.

I’m am working on a bit code that uses an ExtendedTimer to periodically check to see if the USB cable has been connected (and eventually fire off an event). This way I can automatically detect the USB cable being connected/disconnected and respond to those events. To make that work I need to know if the MassStorage object was attached/enabled so I don’t try to do it more than once. (Say I wanted a device to switch automatically to MassStorage mode when the USB cable is inserted.)


#4

The state is not related to mass storage… It is for USB connection.
You can have a thread that polls connection every second or so, similar to what you have.