Re: [EE] Saving "printf" arguments for later? Real-time on slow processor.

smplx <[email protected]>
Newsgroups gmane.comp.hardware.microcontrollers.pic
Message-ID <[email protected]>
As I've received several requests for help offlist on this matter I've 
decided to produce some software that might be useful to many other 
piclist members. Basically it processes a C source file and replaces 
printf function calls with seperate function calls according to the format 
string aqnd list or parameters. These functions need to be written by the 
user but are very simple (basically store value in a buffer or send it in 
binary or hex). Currently there are 2 result formats available but more 
can easily be added if needed. I suggest you use the C preprocessor to 
generate the C source, then pass that through alt_printf (which is very 
fast) then through the second stage of the compiler. Doing it this way 
will make sure that comments are stripped and manifest constants and 
macros are processed correctly by alt_printf.

You can find the source code here:

http://xcprod.com/ALT_PRINTF/alt_printf.tgz

Happy debugging.

Best Regards
Sergio Masci


On Thu, 23 Jan 2025, Allen Mulvey wrote:

> I had been following this thread with some interest. Some time ago I ran into 
> something quite peculiar involving printf. In recent years I have used, 
> almost exclusively, ESP devices, mostly ESP32. My code is full of 
> Serial.print Serial.println statements so I can follow the program flow in 
> trial runs. I would occasionally get a device that compiled well apparently 
> with plenty of resources to spare but the device would get into a continual 
> reboot loop at runtime. Somewhere I read that this was caused by the 
> Serial.print statements and replacing them with one printf statement would 
> fix the problem. To me this seemed counter-intuitive. I expected printf to 
> have much more overhead. But it works! I now use printf whenever there is 
> more than one variable to display and sometimes even for only one. I have no 
> idea why this is. Does anyone know? Thanks.
>
> My IDE is Arduino with which I have had an ongoing love / hate relationship. 
> I keep saying I need to get something better but I really don't want to 
> endure another learning curve.
>
> Thanks again,
> Allen Mulvey
> -- 
> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
> View/change your membership options at
> https://mailman.mit.edu/mailman/listinfo/piclist
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.