7 #include "../../../include/librealsense2/h/rs_internal.h" 8 #include "../../../common/parser.hpp" 12 JNIEXPORT jbyteArray JNICALL
16 jbyte *
buffer = env->GetByteArrayElements(buffer_,
NULL);
17 jsize
length = env->GetArrayLength(buffer_);
20 std::shared_ptr<const rs2_raw_data_buffer> response_bytes(
30 env->ReleaseByteArrayElements(buffer_, buffer, 0);
31 jbyteArray rv = env->NewByteArray(response_size);
32 env->SetByteArrayRegion (rv, 0, response_size, reinterpret_cast<const jbyte *>(response_start));
38 JNIEXPORT jbyteArray JNICALL
43 const char *
file_path = env->GetStringUTFChars(filePath, 0);
44 const char *
line = env->GetStringUTFChars(command, 0);
46 std::ifstream
f(file_path);
47 std::string xml_content((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
52 std::shared_ptr<rs2_terminal_parser> terminal_parser = std::shared_ptr<rs2_terminal_parser>(
58 int line_length = strlen(line);
59 std::shared_ptr<const rs2_raw_data_buffer> command_buffer(
71 std::shared_ptr<const rs2_raw_data_buffer> response_bytes(
82 std::shared_ptr<const rs2_raw_data_buffer> response_buffer(
84 (
void*)response_start, response_size, &e),
91 const unsigned char* response_buffer_start =
rs2_get_raw_data(response_buffer.get(), &
e);
95 env->ReleaseStringUTFChars(command, line);
96 env->ReleaseStringUTFChars(filePath, file_path);
99 jbyteArray rv = env->NewByteArray(response_buffer_size);
100 env->SetByteArrayRegion(rv, 0, response_buffer_size,
101 reinterpret_cast<const jbyte *>(response_buffer_start));
107 JNIEXPORT jobjectArray JNICALL
110 const char *
file_path = env->GetStringUTFChars(filePath, 0);
117 rv = (jobjectArray)env->NewObjectArray(cmd_xml.
commands.size(), env->FindClass(
"java/lang/String"),env->NewStringUTF(
""));
120 env->SetObjectArrayElement(rv, i++, env->NewStringUTF(
c.first.c_str()));
122 env->ReleaseStringUTFChars(filePath, file_path);
bool parse_xml_from_file(const std::string &xml_full_file_path, commands_xml &cmd_xml)
GLuint64 GLenum void * handle
const unsigned char * rs2_get_raw_data(const rs2_raw_data_buffer *buffer, rs2_error **error)
void handle_error(JNIEnv *env, rs2_error *error)
GLsizei const GLchar *const * string
void rs2_delete_raw_data(const rs2_raw_data_buffer *buffer)
int rs2_get_raw_data_size(const rs2_raw_data_buffer *buffer, rs2_error **error)
rs2_raw_data_buffer * rs2_terminal_parse_response(rs2_terminal_parser *terminal_parser, const char *command, unsigned int size_of_command, const void *response, unsigned int size_of_response, rs2_error **error)
Parses terminal response via RealSense terminal parser.
std::map< std::string, command_from_xml > commands
rs2_raw_data_buffer * rs2_terminal_parse_command(rs2_terminal_parser *terminal_parser, const char *command, unsigned int size_of_command, rs2_error **error)
Parses terminal command via RealSense terminal parser.
const rs2_raw_data_buffer * rs2_send_and_receive_raw_data(rs2_device *device, void *raw_data_to_send, unsigned size_of_raw_data_to_send, rs2_error **error)
void rs2_delete_terminal_parser(rs2_terminal_parser *terminal_parser)
Deletes RealSense terminal parser.
JNIEXPORT jbyteArray JNICALL Java_com_intel_realsense_librealsense_DebugProtocol_nSendAndReceiveData(JNIEnv *env, jclass clazz, jlong handle, jstring filePath, jstring command)
GLenum GLuint GLenum GLsizei length
JNIEXPORT jobjectArray JNICALL Java_com_intel_realsense_librealsense_DebugProtocol_nGetCommands(JNIEnv *env, jclass clazz, jstring filePath)
rs2_terminal_parser * rs2_create_terminal_parser(const char *xml_content, rs2_error **error)
Creates RealSense terminal parser.
JNIEXPORT jbyteArray JNICALL Java_com_intel_realsense_librealsense_DebugProtocol_nSendAndReceiveRawData(JNIEnv *env, jclass type, jlong handle, jbyteArray buffer_)