-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conversation
src/main/io/serial.c
Outdated
@@ -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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense
src/main/common/memory.c
Outdated
@@ -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()); |
There was a problem hiding this comment.
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
src/main/io/serial.c
Outdated
@@ -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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
1de0f10
to
a4baca3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@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). |
Agreed. Let's just drop SYNC and make everything async. We need to consider that |
@fiam can you fix conflicts? |
637c4c8
to
c994e50
Compare
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
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.