Home |
Function RTURegisterCallback Function RTUWaitInitialEnumDone |
Function RTURegisterCallbackRTURegisterCallback registers an attachment callback: typedef enum { RTUConnect, RTUDisconnect } RTUSBEvent; typedef void (RTTAPI * RTUConnectCallback)(RTUDeviceHandle Device, RTUSBEvent Event); void RTURegisterCallback(RTUConnectCallback Callback); ParametersCallbackFunction to be called for every device attachment. At most 31 such callbacks can be installed. When a device is attached to the USB, the RTUSB-32 internal hub driver resets the device, assigns a device address, and retrieves the device descriptor and all configuration descriptors. These descriptors are cached, so functions such as RTUGetDevice, RTUFindInterface, etc. do not need to access the device. The hub driver then calls all attachment callbacks installed with this function in the reverse order of their registration. Parameter Device contains a handle to the newly connected device. Parameter Event is set to value RTUConnect. If a callback intends to handle one or more interfaces of the device, RTUClaimInterface must be called by the callback. In this case, the callback supplied as a parameter to RTUClaimInterface (usually the same function as the one used in RTURegisterCallback) will also be called for device detach events. Clients which do not want to claim an interface but nevertheless want to be informed of Disconnect events can call RTUCallOnDisconnect. When a device is detached from the USB, all callbacks installed with RTUCallOnDisconnect and RTUClaimInterface for the device are called in the order of their registration (i.e., in the reverse order of the RTUConnect events). This time, parameter Event is set to RTUDisconnect. The callback should close all pipes using RTUClosePipe (either immediately or deferred in a separate thread) it had previously opened.
|