| 889 | } |
| 890 | |
| 891 | bool Freenect2DeviceImpl::startStreams(bool enable_rgb, bool enable_depth) |
| 892 | { |
| 893 | LOG_INFO << "starting..."; |
| 894 | if(state_ != Open) return false; |
| 895 | |
| 896 | CommandTransaction::Result serial_result, firmware_result, result; |
| 897 | |
| 898 | if (usb_control_.setVideoTransferFunctionState(UsbControl::Enabled) != UsbControl::Success) return false; |
| 899 | |
| 900 | if (!command_tx_.execute(ReadFirmwareVersionsCommand(nextCommandSeq()), firmware_result)) return false; |
| 901 | firmware_ = FirmwareVersionResponse(firmware_result).toString(); |
| 902 | |
| 903 | if (!command_tx_.execute(ReadHardwareInfoCommand(nextCommandSeq()), result)) return false; |
| 904 | //The hardware version is currently useless. It is only used to select the |
| 905 | //IR normalization table, but we don't have that. |
| 906 | |
| 907 | if (!command_tx_.execute(ReadSerialNumberCommand(nextCommandSeq()), serial_result)) return false; |
| 908 | std::string new_serial = SerialNumberResponse(serial_result).toString(); |
| 909 | |
| 910 | if(serial_ != new_serial) |
| 911 | { |
| 912 | LOG_WARNING << "serial number reported by libusb " << serial_ << " differs from serial number " << new_serial << " in device protocol! "; |
| 913 | } |
| 914 | |
| 915 | if (!command_tx_.execute(ReadDepthCameraParametersCommand(nextCommandSeq()), result)) return false; |
| 916 | setIrCameraParams(DepthCameraParamsResponse(result).toIrCameraParams()); |
| 917 | |
| 918 | if (!command_tx_.execute(ReadP0TablesCommand(nextCommandSeq()), result)) return false; |
| 919 | if(pipeline_->getDepthPacketProcessor() != 0) |
| 920 | pipeline_->getDepthPacketProcessor()->loadP0TablesFromCommandResponse(&result[0], result.size()); |
| 921 | |
| 922 | if (!command_tx_.execute(ReadRgbCameraParametersCommand(nextCommandSeq()), result)) return false; |
| 923 | setColorCameraParams(RgbCameraParamsResponse(result).toColorCameraParams()); |
| 924 | |
| 925 | if (!command_tx_.execute(SetModeEnabledWith0x00640064Command(nextCommandSeq()), result)) return false; |
| 926 | if (!command_tx_.execute(SetModeDisabledCommand(nextCommandSeq()), result)) return false; |
| 927 | |
| 928 | int timeout = 50; // about 5 seconds (100ms x 50) |
| 929 | for (uint32_t status = 0, last = 0; (status & 1) == 0 && 0 < timeout; last = status, timeout--) |
| 930 | { |
| 931 | if (!command_tx_.execute(ReadStatus0x090000Command(nextCommandSeq()), result)) return false; |
| 932 | status = Status0x090000Response(result).toNumber(); |
| 933 | if (status != last) |
| 934 | LOG_DEBUG << "status 0x090000: " << status; |
| 935 | if ((status & 1) == 0) |
| 936 | this_thread::sleep_for(chrono::milliseconds(100)); |
| 937 | } |
| 938 | if (timeout == 0) { |
| 939 | LOG_DEBUG << "status 0x090000: timeout"; |
| 940 | } |
| 941 | |
| 942 | if (!command_tx_.execute(InitStreamsCommand(nextCommandSeq()), result)) return false; |
| 943 | |
| 944 | if (usb_control_.setIrInterfaceState(UsbControl::Enabled) != UsbControl::Success) return false; |
| 945 | |
| 946 | if (!command_tx_.execute(ReadStatus0x090000Command(nextCommandSeq()), result)) return false; |
| 947 | LOG_DEBUG << "status 0x090000: " << Status0x090000Response(result).toNumber(); |
| 948 |
no test coverage detected