none
Restart device in C++? RRS feed

  • Question

  • I need to be able to shutdown and restart a connected device from C++.  Shutting down is no problem, but them I am unable to restart the device.

    This is my routine which shuts down the device.  mSensor is my sensor instance.  This works fine:

    if ( mSensor != 0 ) {
    mSensor->NuiShutdown();
    if ( mSensor ) {
    mSensor->Release();
    mSensor = 0;
    }
    }


    This is the routine which starts the device.  It works fine when I first start it.  If I run this again after shutting down the device, the application hangs.

    if ( mSensor == 0 ) {
    	if ( FAILED( NuiCreateSensorByIndex( 0, &mSensor ) ) ) {
    		trace( "Unable to create device instance" );
    		return;
    	}
    }
    
    unsigned long flags = NUI_INITIALIZE_FLAG_USES_DEPTH | NUI_INITIALIZE_FLAG_USES_COLOR;
    if ( FAILED( mSensor->NuiInitialize( flags ) ) ) {
    	trace( "Unable to initialize device " + toString( mDeviceIndex ) );
    	return;
    }
    
    Any ideas?

    Tuesday, May 15, 2012 5:35 PM

All replies

  • There is a known issue that you may be running up against. Are you using SetDeviceSTatusCallback? 

    http://www.microsoft.com/en-us/kinectforwindows/develop/release-notes.aspx#_6._known_issues
    If C++ code is executing NuiInitializa/NuiShutdown multiple times through the application's lifetime, SetDeviceStatusCallback should be called once, before invoking those calls.

    Tuesday, May 15, 2012 8:50 PM
  • Yes, I am. Calling shutdown does not actually trigger the callback.  SetDeviceStatusCallback seems to fire only when physically disconnecting / reconnecting the device (which is a very nice feature).

    What I'm trying to do is allow a user to select from multiple devices.  I'd like to be able to both start multiple devices to stitch the image, as well as toggle between them (ie, only use device 0 or 1).  After shutting one down, it hangs when it comes back.

    Wednesday, May 16, 2012 3:48 PM
  • if you only use one device are you able to stop and start without any issues?
    Wednesday, May 16, 2012 9:18 PM
  • No.  I'm working on getting one device to restart before I attempt to add more.
    Friday, May 18, 2012 5:18 PM
  • A little more exploration... it looks like the device initializes OK, but then I don't get any new data.  NuiImageStreamGetNextFrame results in an E_NUI_FRAME_NO_DATA error.
    Saturday, May 19, 2012 1:39 AM