Skip to content

Commit 0b3eae0

Browse files
committed
usb: Add 5 seconds limit to the status 0x90000 checking loop
1 parent cd77553 commit 0b3eae0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/libfreenect2.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,8 @@ bool Freenect2DeviceImpl::startStreams(bool enable_rgb, bool enable_depth)
735735
if (!command_tx_.execute(SetModeEnabledWith0x00640064Command(nextCommandSeq()), result)) return false;
736736
if (!command_tx_.execute(SetModeDisabledCommand(nextCommandSeq()), result)) return false;
737737

738-
for (uint32_t status = 0, last = 0; (status & 1) == 0; last = status)
738+
int timeout = 50; // about 5 seconds (100ms x 50)
739+
for (uint32_t status = 0, last = 0; (status & 1) == 0 && 0 < timeout; last = status, timeout--)
739740
{
740741
if (!command_tx_.execute(ReadStatus0x090000Command(nextCommandSeq()), result)) return false;
741742
status = Status0x090000Response(result).toNumber();
@@ -744,6 +745,9 @@ bool Freenect2DeviceImpl::startStreams(bool enable_rgb, bool enable_depth)
744745
if ((status & 1) == 0)
745746
this_thread::sleep_for(chrono::milliseconds(100));
746747
}
748+
if (timeout == 0) {
749+
LOG_DEBUG << "status 0x090000: timeout";
750+
}
747751

748752
if (!command_tx_.execute(InitStreamsCommand(nextCommandSeq()), result)) return false;
749753

0 commit comments

Comments
 (0)