diff --git a/latest/Firmware/.cproject b/latest/Firmware/.cproject
index 1b6aa57..41e8205 100644
--- a/latest/Firmware/.cproject
+++ b/latest/Firmware/.cproject
@@ -902,6 +902,8 @@
@@ -942,6 +944,8 @@
diff --git a/latest/Firmware/.settings/language.settings.xml b/latest/Firmware/.settings/language.settings.xml
index 3456f14..1ff1052 100644
--- a/latest/Firmware/.settings/language.settings.xml
+++ b/latest/Firmware/.settings/language.settings.xml
@@ -59,7 +59,7 @@
-
+
diff --git a/latest/Firmware/Inc/CircularQueue.hpp b/latest/Firmware/Inc/CircularQueue.hpp
index 3373081..fd83e5c 100644
--- a/latest/Firmware/Inc/CircularQueue.hpp
+++ b/latest/Firmware/Inc/CircularQueue.hpp
@@ -22,9 +22,9 @@
#define CIRCULARQUEUE_HPP_
+#include
#include "_assert.h"
-
template class CircularQueue
{
public:
@@ -35,7 +35,7 @@ public:
mWritePosition = 0;
mSize = size;
mBuffer = new T[mSize];
- ASSERT(mBuffer);
+ ASSERT_VALID_PTR(mBuffer);
}
inline bool empty()
@@ -77,7 +77,7 @@ private:
volatile int mReadPosition;
volatile int mWritePosition;
size_t mSize;
- volatile T* mBuffer;
+ volatile T* mBuffer = nullptr;
};
#endif /* CIRCULARQUEUE_HPP_ */
diff --git a/latest/Firmware/Inc/EventQueue.hpp b/latest/Firmware/Inc/EventQueue.hpp
index 8dcdf30..ac43a6b 100644
--- a/latest/Firmware/Inc/EventQueue.hpp
+++ b/latest/Firmware/Inc/EventQueue.hpp
@@ -27,6 +27,7 @@
#include "FreeRTOS.h"
#include "queue.h"
+
using namespace std;
class EventQueue
diff --git a/latest/Firmware/Inc/Events.hpp b/latest/Firmware/Inc/Events.hpp
index 8e846c7..6061d97 100644
--- a/latest/Firmware/Inc/Events.hpp
+++ b/latest/Firmware/Inc/Events.hpp
@@ -29,6 +29,7 @@
#include "RXPacket.hpp"
#include "ObjectPool.hpp"
#include "AISChannels.h"
+//#include "RadioManager.hpp"
using namespace std;
@@ -67,23 +68,27 @@ typedef struct {
uint8_t rssi;
} RSSISample;
+
class Event
{
public:
EventType type;
uint32_t flags;
- Event()
- : type(UNKNOWN_EVENT), flags(0) {
- }
+ Event();
+#if 0
Event(EventType t)
- : type(t), flags(0)
+ : type(t), flags(0), rxPacket(nullptr)
{
-
}
+#endif
- RXPacket rxPacket;
+
+ void reset();
+
+ // This is an object, so it can't be a member of the union ...
+ RXPacket *rxPacket;
union {
NMEABuffer nmeaBuffer;
@@ -108,7 +113,7 @@ public:
virtual void processEvent(const Event &event)=0;
};
-#if 1
+
class EventPool
{
public:
@@ -119,11 +124,15 @@ public:
void deleteEvent(Event *event);
uint32_t utilization();
uint32_t maxUtilization();
+ RXPacket *newRXPacket();
+ void releaseRXPacket(RXPacket *);
+private:
+ EventPool();
private:
- ObjectPool *mISRPool;
- ObjectPool *mThreadPool;
+ ObjectPool mISRPool;
+ ObjectPool mThreadPool;
+ ObjectPool mRXPool;
};
-#endif
#endif /* EVENTS_HPP_ */
diff --git a/latest/Firmware/Inc/FreeRTOSConfig.h b/latest/Firmware/Inc/FreeRTOSConfig.h
index f562ac8..ca336f8 100644
--- a/latest/Firmware/Inc/FreeRTOSConfig.h
+++ b/latest/Firmware/Inc/FreeRTOSConfig.h
@@ -64,7 +64,7 @@
#define configTICK_RATE_HZ ((TickType_t)1000)
#define configMAX_PRIORITIES ( 7 )
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
-#define configTOTAL_HEAP_SIZE ((size_t)20480)
+#define configTOTAL_HEAP_SIZE ((size_t)22480)
#define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_16_BIT_TICKS 0
#define configUSE_MUTEXES 0
diff --git a/latest/Firmware/Inc/ObjectPool.hpp b/latest/Firmware/Inc/ObjectPool.hpp
index 61cdb0b..cf747e5 100644
--- a/latest/Firmware/Inc/ObjectPool.hpp
+++ b/latest/Firmware/Inc/ObjectPool.hpp
@@ -41,11 +41,13 @@ public:
mUtilization = 0;
mMaxUtilization = 0;
+ //printf_serial_now("ObjectPool @%p\r\n", this);
for ( uint32_t i = 0; i < mSize; ++i )
{
T *p = new T();
- ASSERT(p);
+ ASSERT_VALID_PTR(p);
mQueue.push(p);
+ //printf_serial_now("\t@%p\r\n", p);
}
}
@@ -61,7 +63,6 @@ public:
mQueue.push(o);
}
-
uint32_t maxUtilization()
{
return mMaxUtilization;
diff --git a/latest/Firmware/Inc/RXPacket.hpp b/latest/Firmware/Inc/RXPacket.hpp
index a185226..f1fba22 100644
--- a/latest/Firmware/Inc/RXPacket.hpp
+++ b/latest/Firmware/Inc/RXPacket.hpp
@@ -25,6 +25,8 @@
#include "_assert.h"
#include "AISChannels.h"
#include "config.h"
+#include "ObjectPool.hpp"
+
using namespace std;
diff --git a/latest/Firmware/Inc/RadioManager.hpp b/latest/Firmware/Inc/RadioManager.hpp
index 0b2c5c5..77ac5a4 100644
--- a/latest/Firmware/Inc/RadioManager.hpp
+++ b/latest/Firmware/Inc/RadioManager.hpp
@@ -30,7 +30,7 @@
#include "AISChannels.h"
-class RadioManager : public GPSDelegate, public EventConsumer
+class RadioManager : public GPSDelegate, EventConsumer
{
public:
static RadioManager &instance();
@@ -49,7 +49,6 @@ public:
void transmitCW(VHFChannel channel);
VHFChannel alternateChannel(VHFChannel channel);
-
private:
RadioManager();
void spiOff();
@@ -58,9 +57,9 @@ private:
Transceiver *mTransceiverIC;
Receiver *mReceiverIC;
bool mInitializing;
-
- CircularQueue *mTXQueue;
time_t mUTC;
+
+ CircularQueue mTXQueue;
};
#endif /* RADIOMANAGER_HPP_ */
diff --git a/latest/Firmware/Inc/Receiver.hpp b/latest/Firmware/Inc/Receiver.hpp
index f5169f6..9d9052a 100644
--- a/latest/Firmware/Inc/Receiver.hpp
+++ b/latest/Firmware/Inc/Receiver.hpp
@@ -57,7 +57,7 @@ protected:
void processNRZIBit(uint8_t level);
virtual void configureGPIOsForRX();
protected:
- RXPacket mRXPacket;
+ RXPacket *mRXPacket = nullptr;
uint16_t mBitWindow;
uint8_t mLastNRZIBit;
uint32_t mBitCount;
diff --git a/latest/Firmware/Inc/Transceiver.hpp b/latest/Firmware/Inc/Transceiver.hpp
index 68ca2e6..6f5ad87 100644
--- a/latest/Firmware/Inc/Transceiver.hpp
+++ b/latest/Firmware/Inc/Transceiver.hpp
@@ -23,10 +23,10 @@
#include "Receiver.hpp"
#include "TXPacket.hpp"
-#include "EventQueue.hpp"
+#include "Events.hpp"
#include