reset-camera.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 #include "../test.h"
5 #include "librealsense2/rs.hpp"
6 #include <condition_variable>
7 #include "hw-monitor.h"
8 
9 using namespace rs2;
10 
12 {
14  std::mutex m;
15  bool disconnected = false;
16  bool connected = false;
18  std::condition_variable cv;
19 
21 
23  if( info.was_removed( dev ) )
24  {
25  std::unique_lock< std::mutex > lock( m );
26  disconnected = true;
27  cv.notify_all();
28  }
29  auto list = info.get_new_devices();
30  if( list.size() > 0 )
31  {
32  for( auto cam : list )
33  {
34  auto new_ser = cam.get_info( RS2_CAMERA_INFO_SERIAL_NUMBER );
35  if( serial == cam.get_info( RS2_CAMERA_INFO_SERIAL_NUMBER ) )
36  {
37  std::unique_lock< std::mutex > lock( m );
38  connected = true;
39  result = cam ;
40 
41  cv.notify_all();
42  break;
43  }
44  }
45  }
46  } );
47 
48  dev.hardware_reset();
49 
50  std::unique_lock< std::mutex > lock( m );
51  REQUIRE(cv.wait_for( lock, std::chrono::seconds( 50 ), [&]() { return disconnected; } ) );
52  REQUIRE( cv.wait_for( lock, std::chrono::seconds( 50 ), [&]() { return connected; } ) );
53  REQUIRE( result );
54  return result;
55 }
static const textual_icon lock
Definition: model-views.h:218
const GLfloat * m
Definition: glext.h:6814
bool was_removed(const rs2::device &dev) const
Definition: rs_context.hpp:23
Definition: cah-model.h:10
GLsizei const GLchar *const * string
rs2::device reset_camera_and_wait_for_connection(rs2::device &dev)
Definition: reset-camera.h:11
def info(name, value, persistent=False)
Definition: test.py:301
REQUIRE(n_callbacks==1)
void hardware_reset()
Definition: rs_device.hpp:90
const char * get_info(rs2_camera_info info) const
Definition: rs_device.hpp:79
static std::condition_variable cv
device_list get_new_devices() const
Definition: rs_context.hpp:57
void set_devices_changed_callback(T callback)
Definition: rs_context.hpp:169
GLuint64EXT * result
Definition: glext.h:10921


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