-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/logging #86
Feature/logging #86
Conversation
Hmm. Ack the |
src/logger.rs
Outdated
pub fn process(&self, terminal: &mut SerialTerminal) { | ||
cortex_m::interrupt::free(|_cs| { | ||
let buffer = unsafe { &mut *self.buffer.get() }; | ||
terminal.write(buffer.data()); |
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.
Doesn't this take quite a while?
It's in a critical section.
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 boils down into a copy into the USB serial output port buffer, so the actual blocking time should just be the amount of time to copy the data - the output isn't actually transmitted over USB here.
I think a bbqueue fits our needs, but it won't eliminate the need for critical sections. The problem is that the global logger is being used across multiple contexts (any task that creates a log will then refer to the global logger). Thus, we need to take care about preemption of the write into the queue from a higher priority task. Essentially, the issue is that The |
Usage of the |
This PR adds a logging facade for booster. The logger implemented serializes the log and stores it in an internal buffer for later transmission by the serial terminal.
When the USB process eventually executes, logs will be written out over the USB serial port.
This fixes #14
Background
log::Log
must bestatic
, which imposes the following design restrictions:const fn
to avoidstatic mut
and unsafe accessHeapless
Vec::new()
is not aconst fn
, so we have to implement our own minimal vector for data buffering, which is implemented here as theLogBuffer
.