diff --git a/knx-linux/CMakeLists.txt b/knx-linux/CMakeLists.txt index 6b2f1ad..064e7a8 100644 --- a/knx-linux/CMakeLists.txt +++ b/knx-linux/CMakeLists.txt @@ -3,76 +3,75 @@ project(knx-linux) set(LIBRARIES_FROM_REFERENCES "") add_executable(knx-linux ../src/knx/address_table_object.cpp - ../src/knx/apdu.cpp - ../src/knx/application_layer.cpp - ../src/knx/application_program_object.cpp - ../src/knx/association_table_object.cpp - ../src/knx/bau.cpp - ../src/knx/bau07B0.cpp - ../src/knx/bau27B0.cpp - ../src/knx/bau57B0.cpp - ../src/knx/bau_systemB.cpp - ../src/knx/bits.cpp - ../src/knx/cemi_frame.cpp - ../src/knx/data_link_layer.cpp - ../src/knx/device_object.cpp - ../src/knx/group_object.cpp - ../src/knx/group_object_table_object.cpp - ../src/knx/interface_object.cpp - ../src/knx/ip_data_link_layer.cpp - ../src/knx/ip_parameter_object.cpp - ../src/knx/memory.cpp - ../src/knx/network_layer.cpp - ../src/knx/npdu.cpp - ../src/knx/rf_physical_layer.cpp - ../src/knx/rf_data_link_layer.cpp - ../src/knx/rf_medium_object.cpp - ../src/knx/table_object.cpp - ../src/knx/tpdu.cpp - ../src/knx/tpuart_data_link_layer.cpp - ../src/knx/transport_layer.cpp - ../src/knx/platform.cpp ../src/knx/address_table_object.h + ../src/knx/apdu.cpp ../src/knx/apdu.h + ../src/knx/application_layer.cpp ../src/knx/application_layer.h + ../src/knx/application_program_object.cpp ../src/knx/application_program_object.h + ../src/knx/association_table_object.cpp ../src/knx/association_table_object.h + ../src/knx/bau.cpp ../src/knx/bau.h + ../src/knx/bau07B0.cpp ../src/knx/bau07B0.h + ../src/knx/bau27B0.cpp ../src/knx/bau27B0.h + ../src/knx/bau57B0.cpp ../src/knx/bau57B0.h + ../src/knx/bau_systemB.cpp ../src/knx/bau_systemB.h + ../src/knx/bits.cpp ../src/knx/bits.h + ../src/knx/cemi_frame.cpp ../src/knx/cemi_frame.h + ../src/knx/data_link_layer.cpp ../src/knx/data_link_layer.h + ../src/knx/device_object.cpp ../src/knx/device_object.h - ../src/knx/group_object.h - ../src/knx/group_object_table_object.h - ../src/knx/interface_object.h - ../src/knx/ip_data_link_layer.h - ../src/knx/ip_parameter_object.h - ../src/knx/memory.h - ../src/knx/network_layer.h - ../src/knx/npdu.h - ../src/knx/rf_physical_layer.h - ../src/knx/rf_data_link_layer.h - ../src/knx/rf_medium_object.h - ../src/knx/table_object.h - ../src/knx/tpdu.h - ../src/knx/tpuart_data_link_layer.h - ../src/knx/transport_layer.h - ../src/knx/platform.h - main.cpp - ../src/linux_platform.h - ../src/knx_facade.h - ../src/knx/dptconvert.h - ../src/knx/knx_value.h + ../src/knx/dpt.cpp ../src/knx/dpt.h - ../src/linux_platform.cpp - ../src/knx_facade.cpp ../src/knx/dptconvert.cpp + ../src/knx/dptconvert.h + ../src/knx/group_object.cpp + ../src/knx/group_object.h + ../src/knx/group_object_table_object.cpp + ../src/knx/group_object_table_object.h + ../src/knx/interface_object.cpp + ../src/knx/interface_object.h + ../src/knx/ip_data_link_layer.cpp + ../src/knx/ip_data_link_layer.h + ../src/knx/ip_parameter_object.cpp + ../src/knx/ip_parameter_object.h ../src/knx/knx_value.cpp - ../src/knx/dpt.cpp) + ../src/knx/knx_value.h + ../src/knx/memory.cpp + ../src/knx/memory.h + ../src/knx/network_layer.cpp + ../src/knx/network_layer.h + ../src/knx/npdu.cpp + ../src/knx/npdu.h + ../src/knx/platform.h + ../src/knx/rf_data_link_layer.cpp + ../src/knx/rf_data_link_layer.h + ../src/knx/rf_medium_object.cpp + ../src/knx/rf_medium_object.h + ../src/knx/rf_physical_layer.cpp + ../src/knx/rf_physical_layer.h + ../src/knx/table_object.cpp + ../src/knx/table_object.h + ../src/knx/tpdu.cpp + ../src/knx/tpdu.h + ../src/knx/tpuart_data_link_layer.cpp + ../src/knx/tpuart_data_link_layer.h + ../src/knx/transport_layer.cpp + ../src/knx/transport_layer.h + ../src/knx_facade.cpp + ../src/knx_facade.h + ../src/linux_platform.cpp + ../src/linux_platform.h + main.cpp) target_link_libraries(knx-linux "${LIBRARIES_FROM_REFERENCES}") include_directories(../src) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wno-unknown-pragmas -Wno-switch -g -O0") diff --git a/knx-linux/knx-linux.vcxproj b/knx-linux/knx-linux.vcxproj index 0d59f71..c0b62f8 100644 --- a/knx-linux/knx-linux.vcxproj +++ b/knx-linux/knx-linux.vcxproj @@ -145,7 +145,6 @@ - diff --git a/knx-linux/knx-linux.vcxproj.filters b/knx-linux/knx-linux.vcxproj.filters index bf11c0a..f26dfd5 100644 --- a/knx-linux/knx-linux.vcxproj.filters +++ b/knx-linux/knx-linux.vcxproj.filters @@ -217,9 +217,6 @@ Source files\knx - - Source files\knx - Source files\knx diff --git a/src/knx/platform.cpp b/src/knx/platform.cpp deleted file mode 100644 index eaf18bb..0000000 --- a/src/knx/platform.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "platform.h" -#include "knx/bits.h" - -#include - -uint8_t* Platform::memoryReference() -{ - return _memoryReference; -} - - -uint8_t* Platform::allocMemory(size_t size) -{ - uint8_t* address = (uint8_t*)malloc(size); -// if (_memoryReference == 0 || address < _memoryReference) -// _memoryReference = address; - print("MemRef: "); - print((long unsigned int)_memoryReference, HEX); - print(" Mem: "); - print((long unsigned int)address, HEX); - print(" Diff: "); - println((long unsigned int)(address - _memoryReference)); - return address; -} - -void Platform::freeMemory(uint8_t* ptr) -{ - free(ptr); -} - - -Platform::Platform() -{ - // allocate memory to have a memory reference, substract a bit - _memoryReference = (uint8_t*)malloc(1); - free(_memoryReference); - _memoryReference -= 1024; -} diff --git a/src/knx/platform.h b/src/knx/platform.h index 50d9bef..dbf5790 100644 --- a/src/knx/platform.h +++ b/src/knx/platform.h @@ -7,7 +7,6 @@ class Platform { public: - Platform(); // ip config virtual uint32_t currentIpAddress() = 0; virtual uint32_t currentSubnetMask() = 0; @@ -48,11 +47,4 @@ class Platform #endif 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: - uint8_t* _memoryReference = 0; }; \ No newline at end of file diff --git a/src/linux_platform.cpp b/src/linux_platform.cpp index e7f8b4a..4f86ba8 100644 --- a/src/linux_platform.cpp +++ b/src/linux_platform.cpp @@ -35,10 +35,7 @@ #define MAX_MEM 4096 LinuxPlatform::LinuxPlatform() -{ - Platform::_memoryReference = (uint8_t*)malloc(MAX_MEM); - _currentMaxMem = Platform::_memoryReference; -} +{} LinuxPlatform::~LinuxPlatform() { @@ -372,25 +369,6 @@ void LinuxPlatform::setupSpi() } -/* - * On linux the memory addresses from malloc may be to big for usermermory_write. - * So we allocate some memory at the beginning and use it for address table, group object table etc. - * - **/ -uint8_t* LinuxPlatform::allocMemory(size_t size) -{ - uint8_t* addr = _currentMaxMem; - _currentMaxMem += size; - if ((_currentMaxMem - Platform::_memoryReference) > MAX_MEM) - throw std::overflow_error("MAX_MEM was to small"); - return addr; -} - -void LinuxPlatform::freeMemory(uint8_t* ptr) -{ - /* do nothing. Memory is freed on restart()*/ -} - void LinuxPlatform::flashFilePath(const std::string path) { _flashFilePath = path; diff --git a/src/linux_platform.h b/src/linux_platform.h index a5605cd..46380ba 100644 --- a/src/linux_platform.h +++ b/src/linux_platform.h @@ -13,8 +13,6 @@ extern int gpio_unexport(int pin); class LinuxPlatform: public Platform { - using Platform::_memoryReference; - using Platform::memoryReference; public: LinuxPlatform(); virtual ~LinuxPlatform(); @@ -57,8 +55,6 @@ public: //memory uint8_t* getEepromBuffer(uint16_t size) override; void commitToEeprom() override; - uint8_t* allocMemory(size_t size) override; - void freeMemory(uint8_t* ptr) override; void cmdlineArgs(int argc, char** argv); private: