Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
unit-tests
func
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
11
inline
rs2::device
reset_camera_and_wait_for_connection
(
rs2::device
&
dev
)
12
{
13
rs2::context
ctx
;
14
std::mutex
m
;
15
bool
disconnected =
false
;
16
bool
connected =
false
;
17
rs2::device
result
;
18
std::condition_variable
cv
;
19
20
std::string
serial = dev.
get_info
(
RS2_CAMERA_INFO_SERIAL_NUMBER
);
21
22
ctx.
set_devices_changed_callback
( [&] (
rs2::event_information
info
)
mutable
{
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
}
rs2::textual_icons::lock
static const textual_icon lock
Definition:
model-views.h:218
rs2::event_information
Definition:
rs_context.hpp:13
test-bad-conditions.dev
dev
Definition:
test-bad-conditions.py:16
m
const GLfloat * m
Definition:
glext.h:6814
RS2_CAMERA_INFO_SERIAL_NUMBER
Definition:
rs_sensor.h:24
rs2::event_information::was_removed
bool was_removed(const rs2::device &dev) const
Definition:
rs_context.hpp:23
rs.hpp
rs2
Definition:
cah-model.h:10
string
GLsizei const GLchar *const * string
Definition:
glad/glad/glad.h:2862
test-got-playback-frames.ctx
ctx
Definition:
test-got-playback-frames.py:165
rs2::context
Definition:
rs_context.hpp:96
reset_camera_and_wait_for_connection
rs2::device reset_camera_and_wait_for_connection(rs2::device &dev)
Definition:
reset-camera.h:11
rspy.test.info
def info(name, value, persistent=False)
Definition:
test.py:301
hw-monitor.h
REQUIRE
REQUIRE(n_callbacks==1)
rs2::device::hardware_reset
void hardware_reset()
Definition:
rs_device.hpp:90
rs2::device::get_info
const char * get_info(rs2_camera_info info) const
Definition:
rs_device.hpp:79
cv
static std::condition_variable cv
Definition:
unit-tests-common.h:613
rs2::event_information::get_new_devices
device_list get_new_devices() const
Definition:
rs_context.hpp:57
rs2::context::set_devices_changed_callback
void set_devices_changed_callback(T callback)
Definition:
rs_context.hpp:169
rs2::device
Definition:
rs_device.hpp:18
result
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