send-hw-monitor-command.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 <hw-monitor.h>
7 
8 #pragma once
9 using namespace rs2;
10 
12 {
14  unsigned int in_cmd, int in_p1 = 0, int in_p2 = 0, int in_p3 = 0, int in_p4 = 0 )
15  : cmd( in_cmd )
16  , p1( in_p1 )
17  , p2( in_p2 )
18  , p3( in_p3 )
19  , p4( in_p4 )
20  {
21  }
22 
23  unsigned int cmd;
24  int p1;
25  int p2;
26  int p3;
27  int p4;
28 };
29 
30 inline std::vector< uint8_t > send_command_and_check( rs2::debug_protocol dp,
32  uint32_t expected_size_return = 0 )
33 {
34  const int MAX_HW_MONITOR_BUFFER_SIZE = 1024;
35 
36  std::vector< uint8_t > res( MAX_HW_MONITOR_BUFFER_SIZE, 0 );
37  int size = 0;
38 
40  command.p1,
41  command.p2,
42  command.p3,
43  command.p4,
44  nullptr,
45  0,
46  res.data(),
47  size );
48 
49  res = dp.send_and_receive_raw_data( res );
50  REQUIRE( res.size() == sizeof( unsigned int ) * ( expected_size_return + 1 ) ); // opcode
51 
52  auto vals = reinterpret_cast< int32_t * >( (void *)res.data() );
53  REQUIRE( vals[0] == command.cmd );
54  res.erase( res.begin(), res.begin() + sizeof( unsigned int ) ); // remove opcode
55 
56  return res;
57 }
hw_monitor_command(unsigned int in_cmd, int in_p1=0, int in_p2=0, int in_p3=0, int in_p4=0)
std::vector< uint8_t > send_command_and_check(rs2::debug_protocol dp, hw_monitor_command command, uint32_t expected_size_return=0)
Definition: cah-model.h:10
static void fill_usb_buffer(int opCodeNumber, int p1, int p2, int p3, int p4, uint8_t const *data, int dataLength, uint8_t *bufferToSend, int &length)
Definition: hw-monitor.cpp:31
GLsizeiptr size
REQUIRE(n_callbacks==1)
unsigned int uint32_t
Definition: stdint.h:80
std::vector< uint8_t > send_and_receive_raw_data(const std::vector< uint8_t > &input) const
Definition: rs_device.hpp:649
GLuint res
Definition: glext.h:8856
signed int int32_t
Definition: stdint.h:77


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