Thanks Jerzy, precisely I was looking for. We’re still at 1.5.0, so I missed this feature.
https://github.com/apache/mynewt-core/commit/49a8316c83e9d8ac3c59cae47afcec8ed3342728 <https://github.com/apache/mynewt-core/commit/49a8316c83e9d8ac3c59cae47afcec8ed3342728> console: Add locking to console writes Console did not have any access control so far. It could result in multiply tasks writing to the console at the same time when output data would be mixed but it could also result in some more subtle situations when console state is not predictable. This patch renames original console_out function to console_out_nolock, and provides console_out that use locking. I’ll dive into it, Best, Mark Sensoterra Tel +31.6.51298623, Science Park 106, 1098 XG Amsterdam, The Netherlands > Op 21 okt. 2019, om 11:57 heeft Jerzy Kasenberg <jerzy.kasenb...@codecoup.pl> > het volgende geschreven: > > Hi Mark, > > There is a pair of functions console_lock() and console_unlock() that does > just what you want. > > best regards > Jerzy > > niedz., 20 paź 2019 o 09:50 Mark Ruys <mark.r...@sensoterra.com> napisał(a): > >> We have an application with multiple tasks logging to the console using >> console_printf(). So often the console output gets cluttered. What’s the >> best way to prevent this? >> >> I could call console_blocking_mode(), but I read: >> >> /* >> * Blocking transmit. ***Note that this should only be used with console. >> * And only when MCU is about to restart, to write final log messages*** >> * >> * @param dev Uart device in question >> */ >> static inline void >> uart_blocking_tx(struct uart_dev *dev, uint8_t byte) >> { >> dev->ud_funcs.uf_blocking_tx(dev, byte); >> } >> >> So far my best guess would be protect calls to console_printf() with a >> mutex. >> >> Thanks, >> >> Mark