6 #include "../context.h" 7 #include "../ds5/ds5-private.h" 14 #define DEFAULT_TIMEOUT 100 15 #define FW_UPDATE_INTERFACE_NUMBER 0 21 std::vector<uint8_t>
buffer(ptr, ptr +
sizeof(fw_last_version));
22 std::stringstream fw_version;
24 for (
auto i = 1;
i <= buffer.size();
i++)
26 fw_version << delimiter << static_cast<int>(buffer[buffer.size() -
i]);
29 return fw_version.str();
39 "This is often an indication of outdated or missing udev-rules.\n" 40 "If using Debian package, run sudo apt-get install librealsense2-dkms\n" 41 "If building from source, run ./scripts/setup_udev_rules.sh",
60 throw std::runtime_error(
"DFU detach failed!");
64 auto sts = messenger->control_transfer(0xa1,
RS2_DFU_UPLOAD, 0, 0, reinterpret_cast<uint8_t*>(&payload),
sizeof(payload), transferred,
DEFAULT_TIMEOUT);
66 throw std::runtime_error(
"Failed to read info from DFU device!");
83 std::chrono::milliseconds elapsed_milliseconds;
88 auto sts = messenger->control_transfer(0xa1 ,
RS2_DFU_GET_STATUS, 0, 0, (
uint8_t*)&status,
sizeof(status), transferred, 5000);
103 std::this_thread::sleep_for(std::chrono::milliseconds(
DEFAULT_TIMEOUT));
106 elapsed_milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(curr -
start);
107 }
while (elapsed_milliseconds < std::chrono::milliseconds(timeout));
127 s <<
"access failed for " << std::hex <<
_usb_device->get_info().vid <<
":" 130 throw std::runtime_error(s.str().c_str());
143 const size_t transfer_size = 1024;
145 size_t remaining_bytes = fw_image_size;
153 while (remaining_bytes > 0)
157 auto curr_block = ((
uint8_t*)fw_image + offset);
158 auto sts = messenger->control_transfer(0x21 ,
RS2_DFU_DOWNLOAD, block_number, 0, curr_block,
uint32_t(chunk_size), transferred, 5000);
170 throw std::runtime_error(
"Device: " + sn +
" is locked for update.\nUse firmware version higher than: " +
_highest_fw_version);
172 throw std::runtime_error(
"Device: " + sn +
" failed to download firmware\nPlease verify that no other librealsense application is running");
179 float progress = (float)block_number / (
float)blocks_count;
180 LOG_DEBUG(
"fw update progress: " << progress);
181 if (update_progress_callback)
182 update_progress_callback->on_update_progress(progress);
191 throw std::runtime_error(
"Failed to send final FW packet");
207 throw std::runtime_error(
"Firmware manifest failed");
212 throw std::runtime_error(
"try to get sensor from fw loader device");
217 throw std::runtime_error(
"update_device does not support get_sensor API");
242 throw std::runtime_error(
"update_device does not support get_device_data API");
247 throw std::runtime_error(
"update_device does not support get_extrinsics API");
257 return std::vector<tagged_profile>();
serial_number_data serial_number
rs2_camera_info
Read-only strings that can be queried from the device. Not all information attributes are available o...
virtual sensor_interface & get_sensor(size_t i) override
virtual const std::string & get_serial_number() const =0
std::string _physical_port
uint32_t fw_highest_version
virtual bool is_valid() const override
const platform::rs_usb_device _usb_device
GLsizei const GLchar *const * string
virtual std::pair< uint32_t, rs2_extrinsics > get_extrinsics(const stream_interface &stream) const override
virtual std::vector< tagged_profile > get_profiles_tags() const override
status
Defines return codes that SDK interfaces use. Negative values indicate errors, a zero value indicates...
virtual std::shared_ptr< matcher > create_matcher(const frame_holder &frame) const override
std::shared_ptr< rs2_update_progress_callback > update_progress_callback_ptr
update_device(const std::shared_ptr< context > &ctx, bool register_device_notifications, std::shared_ptr< platform::usb_device > usb_device)
def info(name, value, persistent=False)
const std::shared_ptr< context > _context
bool is_error_state() const
virtual void enable_recording(std::function< void(const info_interface &)> recording_function) override
virtual void hardware_reset() override
void read_device_info(std::shared_ptr< platform::usb_messenger > messenger)
std::string _last_fw_version
virtual size_t get_sensors_count() const override
virtual void create_snapshot(std::shared_ptr< info_interface > &snapshot) const override
rs2_dfu_state get_dfu_state(std::shared_ptr< platform::usb_messenger > messenger) const
bool wait_for_state(std::shared_ptr< platform::usb_messenger > messenger, const rs2_dfu_state state, size_t timeout=1000) const
virtual const std::string & get_name() const =0
virtual void update(const void *fw_image, int fw_image_size, update_progress_callback_ptr=nullptr) const override
std::vector< std::shared_ptr< stream_profile_interface >> stream_profiles
virtual std::shared_ptr< context > get_context() const override
virtual const std::string & get_product_line() const =0
virtual platform::backend_device_group get_device_data() const override
LOG_INFO("Log message using LOG_INFO()")
const char * rs2_camera_info_to_string(rs2_camera_info info)
virtual bool compress_while_record() const override
std::string get_formatted_fw_version(uint32_t fw_last_version)
GLbitfield GLuint64 timeout
std::vector< uint8_t > _serial_number_buffer
virtual void tag_profiles(stream_profiles profiles) const override
std::string _highest_fw_version
#define FW_UPDATE_INTERFACE_NUMBER
virtual const std::string & get_info(rs2_camera_info info) const override
virtual bool supports_info(rs2_camera_info info) const override
void detach(std::shared_ptr< platform::usb_messenger > messenger) const
bool is_in_state(const rs2_dfu_state state) const