-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Bluetooth: Shell: Replace ctx_shell with logging #69736
Conversation
568cd3e
to
44d5213
Compare
44d5213
to
e05c154
Compare
Replace uses of ctx_shell with logging. The ctx_shell is mostly (always?) used in callbacks, where spending time to print directly may affect the behavior of the stack, and should be avoided. Logging has other advantages, such as following the order of operations when also logging things from the stack. Some features like the verbose logging of advertising data have been slightly reworked to better work with the logging system. Signed-off-by: Emil Gydesen <[email protected]>
e05c154
to
67f1849
Compare
Looks generally fine, but since all of these are messages that we always want, I think |
Btw, what users of |
I was thinking the same, but my approach to this change was That being said, I don't mind modifying the DBG to INF, as I generally agree with your statement
The audio shell still uses this, which is removed by a subsequent PR (#69739) in order to reduce the number of people involved in reviewing |
@Thalley one thing just occurred to me: won't this break if the shell "transport" is something else than where logging goes to? E.g. logging on uart0 and shell on uart1, or having shell over some completely different transport, etc? Since we really do want the callback output to happen over the same "transport" as where you're entering the shell commands I think the right thing would be to keep using |
@jhedberg that is a good suggestion, and is effectively what is being sought after with this change. You have a good point that the logging may be on a different transport than the shell. I've marked this as DNM until we've concluded that this is a good approach based on your comments. @alwa-nordic @jori-nordic Please provide additional input here :) Asynchronous output would likely be a good thing to add, but I wonder if has the other advantages of this change. I'm not familiar enough the logging or shell subsystems to know why, but I've experienced that Then there are the other advantages of using the logging, such as keeping the order of the shell "prints" together with the logging from the stack, as well as getting information about which function is logging, and timestamps. |
First opinion. I suspect a lot of the slowness could be solved by optimizing the shell, console and UART subsystem chain. E.g. The console-uart implementation outputs a single character at a time to the UART. Second opinion. Instead of ad-hoc background printing, it would be great if the shell got task management (like Ctrl-Z, Having a task in the shell allows that task (running in the shell thread) to be responsible for printing. It's then up to each task to decide if it prints fully async like the log, risking dropping messages, sync or buffered (i.e. async until full). I don't want general async printing. In a lot of cases, I much prefer to slow down some execution rather than lose data. But of course, some tasks are different. Third opinion. I think we should consider a transition away from holding on to a |
This may be for UX purposes. Every time you enter a character, it's echoed back to you, right?
That would be interesting
This effectively sounds a reimplementation of the logging system, but with the shell as context. This, however, won't help the issues we've seen where a
Indeed. When sending audio, you don't want lost data, but when e.g. scanning, missing a scan report won't be a big deal.
I agree. The idea of this global |
I'd assume that @alwa-nordic meant some kind of "output this to all shell instances" API, which sounds like a useful feature to me. Please correct me if I misunderstood :) |
That's right. It was a reference to the Unix command |
Ah. Not sure how a If I run a command with my shell instance, I only expect to get results from this (and previous commands, such as scan reports) in my shell instance. I wouldn't be interested in other shell's data, where I have no context for what they are. |
Results from the UPF is that this modification didn't really provide that much better results. There is clearly still something with the shell prints that affect audio over USB more than log statements (could simply be what thread is doing it, as most of these are likely called in the RX thread). So I still firmly believe that there is an issue that is partially solved by this, and that using the logging system also provide additional benefits (such as keeping the same order when comparing logs from the subsystem to the shell), but as has been pointed out above, this approach may not be the right solution. I'll keep this PR open for a bit more, and if we decide not to use logging instead of the direct print, then we should look for an alternative approach as the current is suboptimal (for multiple reasons). |
Closing this PR as this needs a better solution. Enhancement issue: #70945 |
Replace uses of ctx_shell with logging.
The ctx_shell is mostly (always?) used in callbacks, where spending time to print directly may affect the behavior of the stack, and should be avoided.
Logging has other advantages, such as following the order of operations when also logging things from the stack.