From ee5f1cc32c265d98ccc4234eaf4818ba67110a27 Mon Sep 17 00:00:00 2001 From: tuxedo0801 Date: Fri, 6 Nov 2015 14:39:18 +0100 Subject: [PATCH] Renamed RingBuffer to ActionRingBuffer due to name-conflicts when using Arduino Zero --- RingBuffer.h => ActionRingBuffer.h | 24 +++++++++---------- KnxDevice.cpp | 4 ++-- KnxDevice.h | 6 ++--- KnxTpUart.cpp | 2 ++ .../RingBuffer_UnitTests.ino | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-) rename RingBuffer.h => ActionRingBuffer.h (89%) mode change 100644 => 100755 KnxTpUart.cpp diff --git a/RingBuffer.h b/ActionRingBuffer.h similarity index 89% rename from RingBuffer.h rename to ActionRingBuffer.h index 150703f..8dfb008 100644 --- a/RingBuffer.h +++ b/ActionRingBuffer.h @@ -17,31 +17,31 @@ // along with this program. If not, see . -// File : RingBuffer.h +// File : ActionRingBuffer.h // Author : Franck Marini // Description : Implementation of a generic elements ring buffer // Module dependencies : none -#ifndef RINGBUFFER_H -#define RINGBUFFER_H +#ifndef ACTIONRINGBUFFER_H +#define ACTIONRINGBUFFER_H #include "Arduino.h" // !!!!!!!!!!!!!!! FLAG OPTIONS !!!!!!!!!!!!!!!!! -// #define RINGBUFFER_STAT // To be uncommented when doing Statistics +// #define ACTIONRINGBUFFER_STAT // To be uncommented when doing Statistics // The type of the contained elements and the ring buffer size are defined at compile time (template) // In case of buffer full, a new appended data overwrites the oldest one template -class RingBuffer { +class ActionRingBuffer { byte _head; byte _tail; T _buffer[size]; // elements buffer byte _size; byte _elementsCurrentNb; -#ifdef RINGBUFFER_STAT +#ifdef ACTIONRINGBUFFER_STAT byte _elementsMaxNb; word _lostElementsNb; #endif @@ -49,13 +49,13 @@ class RingBuffer { public : // Constructor - RingBuffer() + ActionRingBuffer() { _head = 0; _tail = 0; _elementsCurrentNb = 0; _size = size; - #ifdef RINGBUFFER_STAT + #ifdef ACTIONRINGBUFFER_STAT _elementsMaxNb = 0; // MAX nb of elements _lostElementsNb = 0; // nb of lost elements #endif @@ -69,14 +69,14 @@ class RingBuffer { if (_elementsCurrentNb == _size) { // buffer is already full, we overwrite the oldest data IncrementHead(); - #ifdef RINGBUFFER_STAT + #ifdef ACTIONRINGBUFFER_STAT _lostElementsNb++; #endif } else { // we still have some free place _elementsCurrentNb++; - #ifdef RINGBUFFER_STAT + #ifdef ACTIONRINGBUFFER_STAT if (_elementsCurrentNb > _elementsMaxNb) _elementsMaxNb++; #endif } @@ -101,7 +101,7 @@ class RingBuffer { byte ElementsNb(void) const { return _elementsCurrentNb; } - #ifdef RINGBUFFER_STAT + #ifdef ACTIONRINGBUFFER_STAT // Return Stat information void Info(String& str) { @@ -118,4 +118,4 @@ class RingBuffer { void IncrementTail(void) { _tail = (_tail + 1) % _size; } }; -#endif // RINGBUFFER_H +#endif // ACTIONRINGBUFFER_H diff --git a/KnxDevice.cpp b/KnxDevice.cpp index f741842..441f5cf 100644 --- a/KnxDevice.cpp +++ b/KnxDevice.cpp @@ -19,7 +19,7 @@ // File : KnxDevice.cpp // Author : Franck Marini // Description : KnxDevice Abstraction Layer -// Module dependencies : HardwareSerial, KnxTelegram, KnxComObject, KnxTpUart, RingBuffer +// Module dependencies : HardwareSerial, KnxTelegram, KnxComObject, KnxTpUart, ActionRingBuffer #include "KnxDevice.h" @@ -39,7 +39,7 @@ KnxDevice::KnxDevice() { _state = INIT; _tpuart = NULL; - _txActionList= RingBuffer(); + _txActionList= ActionRingBuffer(); _initCompleted = false; _initIndex = 0; _rxTelegram = NULL; diff --git a/KnxDevice.h b/KnxDevice.h index 64509af..671607d 100644 --- a/KnxDevice.h +++ b/KnxDevice.h @@ -19,7 +19,7 @@ // File : KnxDevice.h // Author : Franck Marini // Description : KnxDevice Abstraction Layer -// Module dependencies : HardwareSerial, KnxTelegram, KnxComObject, KnxTpUart, RingBuffer +// Module dependencies : HardwareSerial, KnxTelegram, KnxComObject, KnxTpUart, ActionRingBuffer #ifndef KNXDEVICE_H #define KNXDEVICE_H @@ -27,7 +27,7 @@ #include "Arduino.h" #include "KnxTelegram.h" #include "KnxComObject.h" -#include "RingBuffer.h" +#include "ActionRingBuffer.h" #include "KnxTpUart.h" // !!!!!!!!!!!!!!! FLAG OPTIONS !!!!!!!!!!!!!!!!! @@ -105,7 +105,7 @@ class KnxDevice { // The value shall be provided by the end-user e_KnxDeviceState _state; // Current KnxDevice state KnxTpUart *_tpuart; // TPUART associated to the KNX Device - RingBuffer _txActionList; // Queue of transmit actions to be performed + ActionRingBuffer _txActionList; // Queue of transmit actions to be performed boolean _initCompleted; // True when all the Com Object with Init attr have been initialized byte _initIndex; // Index to the last initiated object word _lastInitTimeMillis; // Time (in msec) of the last init (read) request on the bus diff --git a/KnxTpUart.cpp b/KnxTpUart.cpp old mode 100644 new mode 100755 index 8cb6517..c53b1a0 --- a/KnxTpUart.cpp +++ b/KnxTpUart.cpp @@ -87,6 +87,8 @@ byte attempts = 10; // CONFIGURATION OF THE ARDUINO USART WITH CORRECT FRAME FORMAT (19200, 8 bits, parity even, 1 stop bit) _serial.begin(19200,SERIAL_8E1); + //_serial.begin(19200); + //UCSR1C = UCSR1C | B00100000; // Even Parity while(attempts--) { // we send a RESET REQUEST and wait for the reset indication answer diff --git a/examples/UnitTests/RingBuffer_UnitTests/RingBuffer_UnitTests.ino b/examples/UnitTests/RingBuffer_UnitTests/RingBuffer_UnitTests.ino index 9e5728b..cd8592e 100644 --- a/examples/UnitTests/RingBuffer_UnitTests/RingBuffer_UnitTests.ino +++ b/examples/UnitTests/RingBuffer_UnitTests/RingBuffer_UnitTests.ino @@ -1,4 +1,4 @@ -#include // /!\ Turn "RINGBUFFER_STAT" define on in RingBuffer.h to allow statistics info +#include // /!\ Turn "ACTIONRINGBUFFER_STAT" define on in ActionRingBuffer.h to allow statistics info #include // command line interpreter lib available at https://github.com/franckmarini/Cli Cli cli = Cli(Serial);