zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.97k stars 6.68k forks source link

Dictionary logging - Add Framing for more robustness #79905

Open optical-o opened 1 month ago

optical-o commented 1 month ago

I have noticed that for the Dictionary logging, there is no framing present in the format. The issue is that if you have a lossy connection or the Log backend does not store messages aligned exactly to the dictionary structure the parser then fails rendering the whole log "unreadable".

I would suggest implementing some COB or SLIP framing that would allow the dictionary logging to support resyncing in the event of byte drop or miss-aligned storage. It would make the dictionary logging much more functional. This would also allow adding some streaming mode to the parser so you can see the output from serial and etc live.

This should be probably added to the dictionary/database so the parser knows what format to expect to make it backwards compatible with the current solution.

The addition of some database identifier (hash of the dictionary) that would be periodically emitted would also be very handy #76858. Maybe adding an additional dictionary MSG type?

Please let me know what are your thoughts on this or if anyone has already some plans with the logging feature. We might be able to contribute to making this feature more robust.

nordic-krch commented 1 month ago

Good suggestion. I've started some work around COBS few months ago (https://github.com/zephyrproject-rtos/zephyr/compare/main...nordic-krch:zephyr:log_frontend_cobs) but unfortunately I had no time to finish. I will see if I can find some time for it.