Skip to content

Fw logs and terminal parser api fix, wrappers android and C# - #6743

Merged
ev-mp merged 20 commits into
realsenseai:acfrom
remibettan:fw-logs-wrapper-android
Jul 7, 2020
Merged

Fw logs and terminal parser api fix, wrappers android and C##6743
ev-mp merged 20 commits into
realsenseai:acfrom
remibettan:fw-logs-wrapper-android

Conversation

@remibettan

Copy link
Copy Markdown
Contributor

PR triggered by jira ticket DSO-15212.
Fw logs in the android wrapper are now based on the fw logs API which has been recently implemented.

@ev-mp ev-mp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For review

int result = rs2_get_fw_log(reinterpret_cast<rs2_device*>(fw_logger_handle), &log_msg, &e);
handle_error(env, e);

return (jlong)log_msg;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The buffers should be released with rs2_delete_fw_log_message.
Probably RAII?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Java class FwLogMsg which gets this handle - which is actually the pointer of the native allocation - inherits from LrsClass, which inherits from AutoClosable. This ensures that if the instance has been allocated within a "try" call, the close method of the class will be closed at the end of the block after the "try" call.
The rs2_delete_fw_log_message method is called in the close method of the FwLogMsg.

Comment thread src/android/jni/fw_logger.cpp Outdated

int result = rs2_get_flash_log(reinterpret_cast<rs2_device*>(fw_logger_handle), &log_msg, &e);
if (result == 0){
e = rs2_create_error("No more flash logs in flash", "dummy_name", "dummy_args", RS2_EXCEPTION_TYPE_UNKNOWN);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"No more flash logs on flash"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected

Comment thread src/android/jni/fw_logger.cpp
try(RsContext ctx = new RsContext()) {
try (DeviceList devices = ctx.queryDevices()) {
if (devices.getDeviceCount() > 0) {
try (Device device = devices.createDevice(0)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will pick-up the first device found. Add device selection for multi-cam scenario

try(RsContext ctx = new RsContext()){
try(DeviceList devices = ctx.queryDevices()) {
if (devices.getDeviceCount() > 0) {
try (Device device = devices.createDevice(0)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

String fw_logging_file_path = sharedPref.getString(getString(R.string.fw_logging_file_path), "");


if (fw_logging_enabled) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happen if resumeFwLogger is called twice, what will happen to the original thread?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this is not part of the API, this is part of the application.
It is not called twice, I don't think I have to check this issue.

@remibettan
remibettan force-pushed the fw-logs-wrapper-android branch from 4a7d1b6 to e36e49e Compare July 6, 2020 09:11
@remibettan remibettan changed the title Fw logs wrapper android Fw logs and terminal parser api fix, wrappers android and C# Jul 6, 2020
Comment thread src/android/jni/fw_logger.cpp Outdated

int result = rs2_get_flash_log(reinterpret_cast<rs2_device*>(fw_logger_handle), log_msg, &e);
if (result == 0){
e = rs2_create_error("No more logs in flash", "dummy_name", "dummy_args", RS2_EXCEPTION_TYPE_UNKNOWN);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there is need for an error? Returning zero messages is not an exceptional UC.

Comment thread src/android/jni/fw_logger.cpp
if (device != null) {
try (final FwLogger fwLoggerDevice = device.as(Extension.FW_LOGGER)) {
mFwLoggerDevice = fwLoggerDevice;
if (mIsParsingFileInitialized)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be if not initialized ?

} else {
logReceived = logMsg.getTimestamp() + " " +
logMsg.getSeverityStr() + " ";
byte[] buffer = new byte[512];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify reference to c++ code/constant used for hard-coded value

if(device != null) {
try(final FwLogger fwLoggerDevice = device.as(Extension.FW_LOGGER)){
mFwLoggerDevice = fwLoggerDevice;
if (mIsParsingFileInitialized)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@ev-mp ev-mp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ev-mp
ev-mp merged commit 4c6bdf7 into realsenseai:ac Jul 7, 2020
@remibettan
remibettan deleted the fw-logs-wrapper-android branch March 15, 2021 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants