fw-update-device.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2019 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 
7 #include "usb/usb-device.h"
8 
9 namespace librealsense
10 {
11  typedef enum rs2_dfu_status {
13  RS2_DFU_STATUS_TARGET = 0x01, // File is not targeted for use by this device.
14  RS2_DFU_STATUS_FILE = 0x02, // File is for this device, but fails some vendor-specific verification test.
15  RS2_DFU_STATUS_WRITE = 0x03, // Device is unable to write memory.
16  RS2_DFU_STATUS_ERASE = 0x04, // Memory erase function failed.
17  RS2_DFU_STATUS_CHECK_ERASED = 0x05, // Memory erase check failed.
18  RS2_DFU_STATUS_PROG = 0x06, // Program memory function failed.
19  RS2_DFU_STATUS_VERIFY = 0x07, // Programmed memory failed verification.
20  RS2_DFU_STATUS_ADDRESS = 0x08, // Cannot program memory due to received address that is out of range.
21  RS2_DFU_STATUS_NOTDONE = 0x09, // Received DFU_DNLOAD with wLength = 0, but device does not think it has all of the data yet.
22  RS2_DFU_STATUS_FIRMWARE = 0x0A, // Device’s firmware is corrupt.It cannot return to run - time (non - DFU) operations.
23  RS2_DFU_STATUS_VENDOR = 0x0B, // iString indicates a vendor - specific RS2_DFU_STATUS_or.
24  RS2_DFU_STATUS_USBR = 0x0C, // Device detected unexpected USB reset signaling.
25  RS2_DFU_STATUS_POR = 0x0D, // Device detected unexpected power on reset.
26  RS2_DFU_STATUS_UNKNOWN = 0x0E, // Something went wrong, but the device does not know what it was.
27  RS2_DFU_STATUS_STALLEDPKT = 0x0F // Device stalled an unexpected request.
29 
30  typedef enum rs2_dfu_state {
42  } rs2_dfu_state;
43 
44  typedef enum rs2_dfu_command {
53 
59 
61  {
63  bwPollTimeout = 0;
64  bState = RS2_DFU_STATE_DFU_ERROR;
65  iString = 0;
66  }
67 
68  bool is_in_state(const rs2_dfu_state state) const
69  {
70  return bStatus == RS2_DFU_STATUS_OK && bState == state;
71  }
72 
73  bool is_error_state() const { return bState == RS2_DFU_STATE_DFU_ERROR; }
74  bool is_ok() const { return bStatus == RS2_DFU_STATUS_OK; }
75  rs2_dfu_state get_state() { return static_cast<rs2_dfu_state>(bState); }
76  rs2_dfu_status get_status() { return static_cast<rs2_dfu_status>(bStatus); }
77  };
78 
80  {
81  uint8_t serial[6];
82  uint8_t spare[2];
83  };
84 
86  {
94  uint8_t spare2[42];
95  };
96 
98  {
99  public:
100  update_device(const std::shared_ptr<context>& ctx, bool register_device_notifications, std::shared_ptr<platform::usb_device> usb_device);
101  virtual ~update_device();
102 
103  virtual void update(const void* fw_image, int fw_image_size, update_progress_callback_ptr = nullptr) const override;
104 
105  virtual sensor_interface& get_sensor(size_t i) override;
106 
107  virtual const sensor_interface& get_sensor(size_t i) const override;
108 
109  virtual size_t get_sensors_count() const override;
110 
111  virtual void hardware_reset() override;
112 
113  virtual std::shared_ptr<matcher> create_matcher(const frame_holder& frame) const override;
114 
115  virtual std::shared_ptr<context> get_context() const override;
116 
117  virtual platform::backend_device_group get_device_data() const override;
118 
119  virtual std::pair<uint32_t, rs2_extrinsics> get_extrinsics(const stream_interface& stream) const override;
120 
121  virtual bool is_valid() const override;
122 
123  virtual std::vector<tagged_profile> get_profiles_tags() const override;
124 
125  virtual void tag_profiles(stream_profiles profiles) const override;
126 
127  virtual bool compress_while_record() const override;
128 
129  virtual bool contradicts(const stream_profile_interface* a, const std::vector<stream_profile>& others) const override { return false; }
130 
131  //info_interface
132  virtual const std::string& get_info(rs2_camera_info info) const override;
133 
134  virtual bool supports_info(rs2_camera_info info) const override;
135 
136  //recordable
137  virtual void create_snapshot(std::shared_ptr<info_interface>& snapshot) const override;
138 
139  virtual void enable_recording(std::function<void(const info_interface&)> recording_function) override;
140 
141  protected:
142  rs2_dfu_state get_dfu_state(std::shared_ptr<platform::usb_messenger> messenger) const;
143  void detach(std::shared_ptr<platform::usb_messenger> messenger) const;
144  bool wait_for_state(std::shared_ptr<platform::usb_messenger> messenger, const rs2_dfu_state state, size_t timeout = 1000) const;
145  void read_device_info(std::shared_ptr<platform::usb_messenger> messenger);
146 
147 
148  const std::shared_ptr<context> _context;
150  std::vector<uint8_t> _serial_number_buffer;
154  bool _is_dfu_locked = false;
155  };
156 }
rs2_camera_info
Read-only strings that can be queried from the device. Not all information attributes are available o...
Definition: rs_sensor.h:22
const platform::rs_usb_device _usb_device
unsigned short uint16_t
Definition: stdint.h:79
GLsizei const GLchar *const * string
virtual bool contradicts(const stream_profile_interface *a, const std::vector< stream_profile > &others) const override
unsigned char uint8_t
Definition: stdint.h:78
bool is_valid(const plane_3d &p)
Definition: rendering.h:243
std::shared_ptr< rs2_update_progress_callback > update_progress_callback_ptr
Definition: src/types.h:1077
GLboolean GLboolean GLboolean GLboolean a
def info(name, value, persistent=False)
Definition: test.py:301
void update(rs2::update_device fwu_dev, std::vector< uint8_t > fw_image)
const std::shared_ptr< context > _context
usb_device_info get_info(const std::wstring device_wstr)
unsigned int uint32_t
Definition: stdint.h:80
std::vector< std::shared_ptr< stream_profile_interface >> stream_profiles
Definition: streaming.h:165
GLbitfield GLuint64 timeout
std::vector< uint8_t > _serial_number_buffer
int i
def get_extrinsics(src, dst)
Definition: t265_stereo.py:57
std::shared_ptr< usb_device > rs_usb_device
Definition: usb-device.h:29
bool is_in_state(const rs2_dfu_state state) const


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:15