Skip to content

mprintf: A thread safe printf: mprintf library

So, I decided to take this one step further and build a library that hides the details of the mutex and variadic macro. To use the library you will need to:

  1. Go into your libraries directory and make a new directory called ‘mprintf’
  2. Copy these two files into the new directory; mprintf.h mprintf.cpp
  3. Put the #include <mprintf.h> and #include <cserial.h> into all the sketches or programs that will be using mprintf.
  4. Put the following two statements at the beginning of your setup() function

serial_stdout_init(9600);
mprintf_init();

5. use mprintf the same way you would use printf

example: mprintf(“hello world\n”);

Update: 20100118:  make sure your freeRTOS task has more then the minimum stack.  mprintf will not work properly for some value conversions (like int or decimal or anything that requires addition stack depth).  I increased by 2 X (2 * configMINIMAL_STACK_SIZE) and all is well for a while.  I’m working on getting some kind of high water stack report by task so we can see when things are getting read to blow up!).  Note, tasks use stack for their local variables.  Global variables (not welcome) are safer until a good method of reporting predicted stack usage can be generated from the compiler.  Thoughts? send them to me!

2 Comments

  1. ingehechata wrote:

    К наджелудочковым аритмиям (НЖА) относятся аритмии исходящие измедицинская литература скачать бесплатно или вовлекающие в процесс синусовый узел, миокард предсердий (предсердные тахикардии, трепетание предсердий) и атриовентрикулярный узел (атриовентрикулярная узловая реципрокная тахикардия(АВУРТ)). К наджелудочковым аритмиям также относятся атриовентрикулярные реципрокные тахикардии,вскрытие трупа обусловленные наличием дополнительного пути проведения (АВРТ).

    Friday, February 11, 2011 at 10:19 am | Permalink
  2. Henrique Ribeiro wrote:

    Hello. I’m testing the Daugava with Arduino Uno. Minutes © ¡is the moment everything working. © m Pora must use the leave-in serial. Through © s CÃ ³ say the Duino, I Funai § Ã £ o mprintf that you developed. © m Pora this Funa § Ã £ o returns unwanted characters as follows:

    mprintf(“hello world\n”);

    Return:
    9­˜¾öCs
    愈kø®

    Help!

    Friday, December 23, 2011 at 4:04 am | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*