error-common.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2021 Intel Corporation. All Rights Reserved.
3 
4 #include <concurrency.h>
5 
6 // This should be defined, per device type
8 
9 // Loop over all possible hw errors and trigger them. Check that the user callback gets the error.
11  const std::map< uint8_t, std::pair< std::string, rs2_log_severity > > & error_report )
12 {
13  auto depth_sens = dev.first< rs2::depth_sensor >();
14 
15  REQUIRE( depth_sens.supports( RS2_OPTION_ERROR_POLLING_ENABLED ) );
16 
17  std::string notification_description;
19  std::condition_variable cv;
20  std::mutex m;
21 
22  depth_sens.set_notifications_callback( [&]( rs2::notification n ) {
23  std::lock_guard< std::mutex > lock( m );
24 
25  notification_description = n.get_description();
26  severity = n.get_severity();
27  cv.notify_one();
28  } );
29 
30  REQUIRE_NOTHROW( depth_sens.set_option( RS2_OPTION_ERROR_POLLING_ENABLED, 0.1f ) );
31 
32  for( auto i = error_report.begin(); i != error_report.end(); i++ )
33  {
34  trigger_error_or_exit( dev, i->first );
35  std::unique_lock< std::mutex > lock( m );
36  CAPTURE( i->first );
37 
38  auto pred = [&]() {
39  return notification_description.compare( i->second.first ) == 0
40  && severity == i->second.second;
41  };
42  REQUIRE( cv.wait_for( lock, std::chrono::seconds( 5 ), pred ) );
43  }
44 
45  depth_sens.set_option(RS2_OPTION_ERROR_POLLING_ENABLED, 0);
46 }
static const textual_icon lock
Definition: model-views.h:218
GLenum GLuint GLenum severity
void trigger_error_or_exit(const rs2::device &dev, uint8_t num)
const GLfloat * m
Definition: glext.h:6814
rs2_log_severity get_severity() const
Definition: rs_sensor.hpp:64
GLsizei const GLchar *const * string
std::string get_description() const
Definition: rs_sensor.hpp:46
GLdouble n
Definition: glext.h:1966
unsigned char uint8_t
Definition: stdint.h:78
GLuint num
Definition: glext.h:5648
#define CAPTURE(...)
Definition: catch.hpp:17432
REQUIRE(n_callbacks==1)
static std::condition_variable cv
void validate_errors_handling(const rs2::device &dev, const std::map< uint8_t, std::pair< std::string, rs2_log_severity > > &error_report)
Definition: error-common.h:10
T first() const
Definition: rs_device.hpp:52
REQUIRE_NOTHROW(rs2_log(RS2_LOG_SEVERITY_INFO,"Log message using rs2_log()", nullptr))
int i
rs2_log_severity
Severity of the librealsense logger.
Definition: rs_types.h:153
GeneratorWrapper< T > map(Func &&function, GeneratorWrapper< U > &&generator)
Definition: catch.hpp:4271


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