Tyler Weaver
/
rtos_sprintf
Demonstration of the use of sprintf() causing a run time problem with RTOS.
Revision 0:7fecc17e2765, committed 2012-02-16
- Comitter:
- tylerjw
- Date:
- Thu Feb 16 14:03:52 2012 +0000
- Commit message:
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Feb 16 14:03:52 2012 +0000 @@ -0,0 +1,29 @@ +#include "mbed.h" +#include "rtos.h" + +DigitalOut led1(LED1); +DigitalOut led2(LED2); + +char* teststring = ""; +int testint = 65; + +// uncomment only one of the sprintf functions at a time to see it fail at that point + +void led2_thread(void const *argument) { + while (true) { + led2 = !led2; + //sprintf(teststring, "This is a test: %d", testint); + Thread::wait(1000); + } +} + +int main() { + Thread thread(led2_thread); + //sprintf(teststring, "This is a test: %d", testint); + + while (true) { + led1 = !led1; + sprintf(teststring, "This is a test: %d", testint); + Thread::wait(500); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Feb 16 14:03:52 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/14f4805c468c