7 years, 7 months ago.

Weird problem. Extraputty print out every 10~20seconds.

debugging

#include "mbed.h"
int a;
int main()
{
    while(1) {
        wait(1);
        a = a + 1;
        printf("%d", a);
        LED=!LED;
    }
}

I'm encountering this weird problem with ExtraPutty. It will only display datas every 10 to 20seconds. Set baud rate to 9600, 8bit, 1 stop bit, parity none, flow control XON/XOFF Any help?

1 Answer

7 years, 7 months ago.

Hi WB Tan,

This is usually caused because the buffer isn't being flushed between each printf. The way to ensure it gets flushed each time is to print a new line character ('\n') at the end of the string.

So your line:

printf("%d", a);

If you change it to:

printf("%d\n", a);

or for Windows terminals

printf("%d\r\n", a);

You should see it print every second.

Hope that helps!

-Brian

Accepted Answer

Why was this ever changed? I ran into the same issue and it does not make sense. I know that RawSerial will correct this but could you explain? Thanks.

posted by Bill Bellis 31 Aug 2016

It has always worked this way. Using regular Serial also fixes it if I remember correctly. It simply depends on the buffer settings of the C stdio lib. You can manually change them if you want with the right C code.

posted by Erik - 31 Aug 2016

Thank you so much!

posted by WB Tan 31 Aug 2016