remove unused methods of Platform class

This commit is contained in:
Thomas Kunze 2019-12-10 21:44:23 +01:00
parent aa230ee0b9
commit 5d8264555a
7 changed files with 53 additions and 130 deletions

View File

@ -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")

View File

@ -145,7 +145,6 @@
<ClCompile Include="..\src\knx\memory.cpp" />
<ClCompile Include="..\src\knx\network_layer.cpp" />
<ClCompile Include="..\src\knx\npdu.cpp" />
<ClCompile Include="..\src\knx\platform.cpp" />
<ClCompile Include="..\src\knx\rf_data_link_layer.cpp" />
<ClCompile Include="..\src\knx\rf_medium_object.cpp" />
<ClCompile Include="..\src\knx\rf_physical_layer.cpp" />

View File

@ -217,9 +217,6 @@
<ClCompile Include="..\src\knx\npdu.cpp">
<Filter>Source files\knx</Filter>
</ClCompile>
<ClCompile Include="..\src\knx\platform.cpp">
<Filter>Source files\knx</Filter>
</ClCompile>
<ClCompile Include="..\src\knx\table_object.cpp">
<Filter>Source files\knx</Filter>
</ClCompile>

View File

@ -1,38 +0,0 @@
#include "platform.h"
#include "knx/bits.h"
#include <cstdlib>
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;
}

View File

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

View File

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

View File

@ -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: