Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 5:e90d7b6f83cb, committed 2018-02-11
- Comitter:
- kenjiArai
- Date:
- Sun Feb 11 02:04:44 2018 +0000
- Parent:
- 4:342b665fb826
- Commit message:
- use Mbed-os5 dedicated class "CircularBuffer"
Changed in this revision
| RingBuffer.lib | Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/RingBuffer.lib Fri Feb 09 22:31:19 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://os.mbed.com/users/ykuroda/code/RingBuffer/#ea6d02ba96ae
--- a/main.cpp Fri Feb 09 22:31:19 2018 +0000
+++ b/main.cpp Sun Feb 11 02:04:44 2018 +0000
@@ -9,8 +9,8 @@
*
* Started: April 8th, 2016
* Revised: June 13th, 2016
- * Revised: October 22nd, 2017 Run on mbed-OS-5.6.2
* Revised: Feburary 10th, 2018 Not set mac addr but use device name
+ * Revised: Feburary 11th, 2018 use mbed-os5.7.4 with CircularBuffer
*
* Original program (see original.cpp file):
* S130 potential unstability case [closed] by Fabien Comte
@@ -32,7 +32,7 @@
#include "DiscoveredCharacteristic.h"
#include "DiscoveredService.h"
#include "UARTService.h"
-#include "RingBuffer.h"
+#include "CircularBuffer.h"
// Definition -----------------------------------------------------------------
//#define USE_MAC // if you use mac address, please define it
@@ -56,7 +56,7 @@
Serial pc(USBTX, USBRX, 115200);
//Serial pc(P0_3, P0_1, 115200); // for another board
Ticker ticker;
-RingBuffer ser_bf(1536);
+CircularBuffer<char, 1536> ser_bf;
Thread tsk;
// ROM / Constant data --------------------------------------------------------
@@ -175,7 +175,7 @@
void serialRxCallback()
{
- ser_bf.save(pc.getc());
+ ser_bf.push(pc.getc());
rx_isr_busy = true;
tsk.signal_set(0x01);
}
@@ -187,7 +187,7 @@
while(true) {
Thread::signal_wait(0x01);
- if (ser_bf.check() == 0) {
+ if (ser_bf.empty()) {
if (linebf_irq_len != 0) {
linebf_irq[linebf_irq_len] = 0;
adjust_line(linebf_irq);
@@ -195,8 +195,9 @@
uartTXCharacteristic.write(NUM_ONCE, linebf_irq);
}
}
- while(ser_bf.check() != 0) {
- char c = ser_bf.read();
+ while(!ser_bf.empty()) {
+ char c;
+ ser_bf.pop(c);
if (c == '\b') {
linebf_irq_len--;
pc.putc(c);