From 1321d62e400300d15c8826c1655a2a61819e040b Mon Sep 17 00:00:00 2001 From: Thomas Kunze Date: Tue, 2 Jul 2019 23:54:31 +0200 Subject: [PATCH] try an other way to create the memory reference point --- knxPython/VERSION | 2 +- knxPython/setup.py | 2 +- src/knx/platform.cpp | 12 ++++++++++-- src/knx/platform.h | 20 +++++++++++--------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/knxPython/VERSION b/knxPython/VERSION index 9faa1b7..c946ee6 100644 --- a/knxPython/VERSION +++ b/knxPython/VERSION @@ -1 +1 @@ -0.1.5 +0.1.6 diff --git a/knxPython/setup.py b/knxPython/setup.py index a01387a..7fdc391 100644 --- a/knxPython/setup.py +++ b/knxPython/setup.py @@ -78,4 +78,4 @@ setup( cmdclass=dict(build_ext=CMakeBuild), url="https://github.com/thelsing/knx", zip_safe=False -) \ No newline at end of file +) diff --git a/src/knx/platform.cpp b/src/knx/platform.cpp index 19cfcad..83cebb7 100644 --- a/src/knx/platform.cpp +++ b/src/knx/platform.cpp @@ -11,8 +11,8 @@ uint8_t* Platform::memoryReference() uint8_t* Platform::allocMemory(size_t size) { uint8_t* address = (uint8_t*)malloc(size); - if (_memoryReference == 0) - _memoryReference = address; +// if (_memoryReference == 0 || address < _memoryReference) +// _memoryReference = address; return address; } @@ -21,3 +21,11 @@ void Platform::freeMemory(uint8_t* ptr) { free(ptr); } + + +Platform::Platform() +{ + // allocate memory to have a memory reference + _memoryReference = (uint8_t*)malloc(1); + free(_memoryReference); +} diff --git a/src/knx/platform.h b/src/knx/platform.h index 1fba4ac..e680920 100644 --- a/src/knx/platform.h +++ b/src/knx/platform.h @@ -6,9 +6,10 @@ class Platform { -public: + public: + Platform(); virtual uint32_t currentIpAddress() = 0; - virtual uint32_t currentSubnetMask() = 0; + virtual uint32_t currentSubnetMask() = 0; virtual uint32_t currentDefaultGateway() = 0; virtual void macAddress(uint8_t* data) = 0; @@ -16,26 +17,27 @@ public: virtual void restart() = 0; virtual void fatalError() = 0; virtual void mdelay(uint32_t millis) = 0; - + virtual void setupMultiCast(uint32_t addr, uint16_t port) = 0; virtual void closeMultiCast() = 0; virtual bool sendBytes(uint8_t* buffer, uint16_t len) = 0; virtual int readBytes(uint8_t* buffer, uint16_t maxLen) = 0; - + virtual void setupUart() = 0; virtual void closeUart() = 0; virtual int uartAvailable() = 0; virtual size_t writeUart(const uint8_t data) = 0; - virtual size_t writeUart(const uint8_t *buffer, size_t size) = 0; + virtual size_t writeUart(const uint8_t* buffer, size_t size) = 0; virtual int readUart() = 0; - virtual size_t readBytesUart(uint8_t *buffer, size_t length) = 0; - + virtual size_t readBytesUart(uint8_t* buffer, size_t length) = 0; + virtual uint8_t* getEepromBuffer(uint16_t size) = 0; virtual void commitToEeprom() = 0; - + virtual uint8_t* memoryReference(); virtual uint8_t* allocMemory(size_t size); virtual void freeMemory(uint8_t* ptr); -protected: + + protected: uint8_t* _memoryReference = 0; }; \ No newline at end of file