try an other way to create the memory reference point

This commit is contained in:
Thomas Kunze 2019-07-02 23:54:31 +02:00
parent 197203b88e
commit 1321d62e40
4 changed files with 23 additions and 13 deletions

View File

@ -1 +1 @@
0.1.5
0.1.6

View File

@ -78,4 +78,4 @@ setup(
cmdclass=dict(build_ext=CMakeBuild),
url="https://github.com/thelsing/knx",
zip_safe=False
)
)

View File

@ -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);
}

View File

@ -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;
};