Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace DEBUG_TRACE with LOG #4385

Merged
merged 2 commits into from
Mar 19, 2019
Merged

Replace DEBUG_TRACE with LOG #4385

merged 2 commits into from
Mar 19, 2019

Conversation

fiam
Copy link
Member

@fiam fiam commented Feb 18, 2019

LOG system has multiple levels, selectable both at compile and run
times. FEATURE_TRACE has been removed, since we now rely just on
the log level/topic and the defined outputs for the log messages.

@fiam fiam added this to the 2.2 milestone Feb 18, 2019
@@ -115,7 +115,7 @@ void pgResetFn_serialConfig(serialConfig_t *serialConfig)
serialConfig->portConfigs[i].peripheral_baudrateIndex = BAUD_115200;
}

serialConfig->portConfigs[0].functionMask = FUNCTION_MSP | FUNCTION_DEBUG_TRACE;
serialConfig->portConfigs[0].functionMask = FUNCTION_MSP | FUNCTION_LOG;
Copy link
Member Author

@fiam fiam Feb 18, 2019

Choose a reason for hiding this comment

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

Probably we should revert this and not set FUNCTION_LOG by default on any ports. The intention is to leave at least error messages always enabled and written to blackbox. Otherwise we might be sending LOG frames via MSP to callers that are not ready for it (specially MSPv1 only callers).

Since FEATURE_DEBUG_TRACE is now gone, enabling logging shouldn't be as painful as enabling debug trace was.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense

@@ -50,11 +52,11 @@ void * memAllocate(size_t wantedSize, resourceOwner_e owner)
retPointer = &dynHeap[dynHeapFreeWord];
dynHeapFreeWord += wantedWords;
dynHeapUsage[owner] += wantedWords * sizeof(uint32_t);
DEBUG_TRACE("Memory allocated. Free memory = %d", memGetAvailableBytes());
LOG_E(SYSTEM, "Memory allocated. Free memory = %d", memGetAvailableBytes());
Copy link
Member

Choose a reason for hiding this comment

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

This is DEBUG or INFO, not ERROR

@@ -115,7 +115,7 @@ void pgResetFn_serialConfig(serialConfig_t *serialConfig)
serialConfig->portConfigs[i].peripheral_baudrateIndex = BAUD_115200;
}

serialConfig->portConfigs[0].functionMask = FUNCTION_MSP | FUNCTION_DEBUG_TRACE;
serialConfig->portConfigs[0].functionMask = FUNCTION_MSP | FUNCTION_LOG;
Copy link
Member

Choose a reason for hiding this comment

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

Makes sense

}
}
} else if (mspLogPort) {
mspSerialPushPort(MSP_DEBUGMSG, (uint8_t*)buf, size, mspLogPort, MSP_V2_NATIVE);
Copy link
Member

Choose a reason for hiding this comment

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

This is actually dangerous. MSP on unconnected VCP will hang, could be very dangerous in flight.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ooops. Good catch! Thing is, we might also want sync messages when debugging to make the FC wait for the listener to connect. Maybe we can get rid of the _SYNC macros and add a setting to make all logging statements sync? In any case, I'll make the code path for synchronous logging check the arming state before blocking.

@fiam fiam force-pushed the agh_log branch 3 times, most recently from 1de0f10 to a4baca3 Compare February 21, 2019 09:26
Copy link
Member

@digitalentity digitalentity left a comment

Choose a reason for hiding this comment

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

LGTM

@fiam
Copy link
Member Author

fiam commented Mar 3, 2019

@digitalentity We need to discuss what to do with the SYNC macros as well as handling the "push-to-MSP" in the safer way possible.

My vote for the first is to just drop them and use a setting to make all logging statements synchronous (and maybe make it block arming when it's enabled).

For the latter, I think we should just skip logging over MSP when the craft is armed and change the VCP driver to avoid blocking if there's nothing connected (or add a timeout if there's no reliable way to detect a connection).

@digitalentity
Copy link
Member

Agreed. Let's just drop SYNC and make everything async.

We need to consider that mspSerialPushPort is blocking when sending a buffer that doesn't fit into VCP tx buffer. It will block indefinitely when VCP is not connected.

@digitalentity
Copy link
Member

@fiam can you fix conflicts?

@fiam fiam force-pushed the agh_log branch 4 times, most recently from 637c4c8 to c994e50 Compare March 15, 2019 10:00
fiam added 2 commits March 18, 2019 19:33
LOG system has multiple levels, selectable both at compile and run
times. FEATURE_TRACE has been removed, since we now rely just on
the log level/topic and the defined outputs for the log messages.
Make all logging asynchronous
@fiam fiam merged commit 1f715de into development Mar 19, 2019
@fiam fiam deleted the agh_log branch March 19, 2019 11:02
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