Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 2 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
8 years, 2 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
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 31 Aug 2016