[EE] Saving "printf" arguments for later? Real-time on slow processor.
Jason White <[email protected]>
| Newsgroups | gmane.comp.hardware.microcontrollers.pic |
|---|---|
| Message-ID | <CAOFvGD4aOuD0dKz9fsX_unQjYQYhCeoDb-AXOn4BhW_QW+F8Fg@mail.gmail.com> |
I've got a situation where I am running a very slow processor that happens to have a lot of spare RAM. The CPU sits idle half of the time. It has some real time processing that it must do on time every handful of seconds. It is just barely fast enough to do its real time work without printfs. The device firmware interfaces with a huge complicated third party library. This library implements a "debug mode" where it calls printf in various places. In debug mode it easily generates several kilobytes of formatted number containing text per minute. And, what the library does is so complicated that we really need the debug output to be generated all of the time (both in development and production). Unfortunately, It turns out that printf is so slow that it causes the system to fail in a variety of subtle yet completely catastrophic ways. (due to it missing real time deadlines and not being able to detect that it has missed them) Has anyone dealt with this before? I've reached the conclusion that my best bet is to write a wrapper for printf. The wrapper would save the printf format string, and variadic arguments to a buffer so that I can process the printfs later when the CPU is idle. I think I can get away with this since all of the printfs just contain numbers and short (~8 byte) strings. I'd be interested to hear other people's thoughts and experiences with this sort of problem. -- Jason White