This example shows how to use the CircularBuffer library.
Dependencies: CircularBuffer mbed
Revision 0:aad8c5c41dac, committed 2013-09-20
- Comitter:
- feb11
- Date:
- Fri Sep 20 10:47:53 2013 +0000
- Commit message:
- initial import
Changed in this revision
diff -r 000000000000 -r aad8c5c41dac CircularBuffer.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CircularBuffer.lib Fri Sep 20 10:47:53 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/feb11/code/CircularBuffer/#e15dee1d59ee
diff -r 000000000000 -r aad8c5c41dac main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Sep 20 10:47:53 2013 +0000 @@ -0,0 +1,19 @@ +#include "mbed.h" +#include "CircularBuffer.h" + +int main() +{ + CircularBuffer<16> buffer; + uint32_t n = buffer.write((uint8_t*)"Hello World !", strlen("Hello World !")); + printf("wrote %d bytes\n", n); + char str[10]; + n = buffer.read((uint8_t*)str, 5); + str[n] = '\0'; + printf("str=%s\n", str); // prints:Hello + buffer.read((uint8_t*)str, 1); // discard space + n = buffer.read((uint8_t*)str, 7); + str[n] = '\0'; + printf("str=%s\n", str); // prints:World ! + + return 0; +}
diff -r 000000000000 -r aad8c5c41dac mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Sep 20 10:47:53 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9c8f0e3462fb \ No newline at end of file