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.
9 years, 11 months ago.
printf cannot be used in RawSerial class in LPC1549
Dear,
I am trying to use RawSerial to output debug information. I delcare debug serial port as RawSerial class, the system will halt when printf is called, such as RawSerial pc(D1, D0); pc.printf("hello world.\r\n")
I delcare debug serial port as Serial class, the system will work well when printf is called, such as Serial pc(D1, D0); pc.printf("hello world.\r\n")
Does the printf is supported in RawSerial class in LPC1549 platform?
Thanks.
Question relating to:
1 Answer
9 years, 8 months ago.
Hi,
The RawSerial::printf() calls vsnprintf() function to get string length and ARM microlib of online compiler doesn't seem to fully support some of ISO C functions which LPC1549 target build use. https://mbed.org/users/mbed_official/code/mbed-src/file/17565898c031/common/RawSerial.cpp
You can use puts() function instead of printf() for RawSerial class.
RawSerial pc(D1, D0); char tmp[80]; sprintf(tmp, "hello world.\r\n"); pc.puts(tmp);
I hope this helps.
Cheers, Toyo