save WIP on flash api + header reorder

This commit is contained in:
Thomas Kunze 2020-03-19 22:35:33 +01:00
parent 894a54fa7f
commit 4b873aebd6
46 changed files with 325 additions and 132 deletions

View File

@ -41,10 +41,10 @@ KnxFacade<LinuxPlatform, Bau27B0> knx;
long lastsend = 0;
#define CURR knx.getGroupObject(1)
#define MAX knx.getGroupObject(2)
#define MIN knx.getGroupObject(3)
#define RESET knx.getGroupObject(4)
#define GO_CURR knx.getGroupObject(1)
#define GO_MAX knx.getGroupObject(2)
#define GO_MIN knx.getGroupObject(3)
#define GO_RESET knx.getGroupObject(4)
void measureTemp()
{
@ -60,22 +60,22 @@ void measureTemp()
// currentValue *= (670433.28 + 273);
// currentValue -= 273;
println(currentValue);
CURR.value(currentValue);
GO_CURR.value(currentValue);
double max = MAX.value();
double max = GO_MAX.value();
if (currentValue > max)
MAX.value(currentValue);
GO_MAX.value(currentValue);
if (currentValue < (double)MIN.value())
MIN.value(currentValue);
if (currentValue < (double)GO_MIN.value())
GO_MIN.value(currentValue);
}
void resetCallback(GroupObject& go)
{
if (go.value())
{
MAX.valueNoSend(-273.0);
MIN.valueNoSend(670433.28);
GO_MAX.valueNoSend(-273.0);
GO_MIN.valueNoSend(670433.28);
}
}
@ -97,13 +97,13 @@ void setup()
if (knx.configured())
{
CURR.dataPointType(Dpt(9, 1));
MIN.dataPointType(Dpt(9, 1));
MIN.value(670433.28);
MAX.dataPointType(Dpt(9, 1));
MAX.valueNoSend(-273.0);
RESET.dataPointType(Dpt(1, 15));
RESET.callback(resetCallback);
GO_CURR.dataPointType(Dpt(9, 1));
GO_MIN.dataPointType(Dpt(9, 1));
GO_MIN.value(670433.28);
GO_MAX.dataPointType(Dpt(9, 1));
GO_MAX.valueNoSend(-273.0);
GO_RESET.dataPointType(Dpt(1, 15));
GO_RESET.callback(resetCallback);
printf("Timeout: %d\n", knx.paramWord(0));
printf("Zykl. senden: %d\n", knx.paramByte(2));
printf("Min/Max senden: %d\n", knx.paramByte(3));

View File

@ -1,7 +1,9 @@
#include "application_program_object.h"
#include "bits.h"
#include "data_property.h"
#include "callback_property.h"
#include <cstring>
ApplicationProgramObject::ApplicationProgramObject(Memory& memory)

View File

@ -1,9 +1,10 @@
#include <cstring>
#include "association_table_object.h"
#include "bits.h"
#include "data_property.h"
#include <cstring>
using namespace std;
AssociationTableObject::AssociationTableObject(Memory& memory)

View File

@ -1,5 +1,7 @@
#include "bau07B0.h"
#include "bits.h"
#include <string.h>
#include <stdio.h>

View File

@ -1,9 +1,12 @@
#include "bau27B0.h"
#ifdef USE_RF
#include "bits.h"
#include <string.h>
#include <stdio.h>
#ifdef USE_RF
using namespace std;
Bau27B0::Bau27B0(Platform& platform)

View File

@ -1,6 +1,8 @@
#include "config.h"
#include "bau57B0.h"
#include "config.h"
#include "bits.h"
#include <string.h>
#include <stdio.h>

View File

@ -1,5 +1,7 @@
#include "bau_systemB.h"
#include "bits.h"
#include <string.h>
#include <stdio.h>

View File

@ -3,6 +3,10 @@
#include <cstddef>
#include <cstdint>
#define MIN(a, b) ((a < b) ? (a) : (b))
#define MAX(a, b) ((a > b) ? (a) : (b))
#define ABS(x) ((x > 0) ? (x) : (-x))
#ifdef __linux__
#include <arpa/inet.h>
@ -10,6 +14,7 @@
#define highByte(val) (((val) >> ((sizeof(val) - 1) << 3)) & 255)
#define bitRead(val, bitno) (((val) >> (bitno)) & 1)
// print functions are implemented in the platform files
#define DEC 10
#define HEX 16

View File

@ -1,6 +1,8 @@
#include "cemi_frame.h"
#include "bits.h"
#include "string.h"
#include <stdio.h>
/*

View File

@ -1,15 +1,17 @@
#include "config.h"
#ifdef USE_CEMI_SERVER
#include "cemi_server.h"
#include "config.h"
#include "cemi_frame.h"
#include "bau_systemB.h"
#include "usb_tunnel_interface.h"
#include "data_link_layer.h"
#include "string.h"
#include "bits.h"
#include <stdio.h>
#ifdef USE_CEMI_SERVER
CemiServer::CemiServer(BauSystemB& bau)
: _bau(bau),
_usbTunnelInterface(*this,

View File

@ -1,11 +1,13 @@
#include "config.h"
#ifdef USE_CEMI_SERVER
#include <cstring>
#include "cemi_server_object.h"
#include "config.h"
#include "bits.h"
#include "data_property.h"
#include <cstring>
#ifdef USE_CEMI_SERVER
CemiServerObject::CemiServerObject()
{
uint16_t mediumType = 0;

View File

@ -14,7 +14,7 @@
#define USE_RF
#define USE_TP
#define USE_IP
//#define USE_USB
#define USE_USB
//#define USE_CEMI_SERVER
#ifdef USE_USB
#define USE_CEMI_SERVER

View File

@ -1,4 +1,5 @@
#include "data_property.h"
#include "bits.h"
#include <cstring>

View File

@ -9,6 +9,7 @@
*/
#include "datapoint_types.h"
#include <stdint.h>
// Sign for a negative DPT9 float value

View File

@ -1,10 +1,12 @@
#include <cstring>
#include "device_object.h"
#include "bits.h"
#include "data_property.h"
#include "callback_property.h"
#include "config.h"
#include <cstring>
#define LEN_KNX_SERIAL 6
DeviceObject::DeviceObject()

View File

@ -1,5 +1,7 @@
#include "dptconvert.h"
#include "bits.h"
#include <cmath>
#include <cstdlib>
#include <cstring>

View File

@ -1,4 +1,5 @@
#include "group_object.h"
#include "bits.h"
#include "string.h"
#include "datapoint_types.h"

View File

@ -1,10 +1,11 @@
#include <cstring>
#include "group_object_table_object.h"
#include "group_object.h"
#include "bits.h"
#include "data_property.h"
#include <cstring>
GroupObjectTableObject::GroupObjectTableObject(Memory& memory)
: TableObject(memory)
{

View File

@ -1,8 +1,9 @@
#include <cstring>
#include "interface_object.h"
#include "data_property.h"
#include <cstring>
InterfaceObject::~InterfaceObject()
{
if (_properties != nullptr)

View File

@ -1,7 +1,5 @@
#include "ip_data_link_layer.h"
#ifdef USE_IP
#include "bits.h"
#include "platform.h"
#include "device_object.h"
@ -13,6 +11,8 @@
#include <stdio.h>
#include <string.h>
#ifdef USE_IP
#define KNXIP_HEADER_LEN 0x6
#define KNXIP_PROTOCOL_VERSION 0x10

View File

@ -1,6 +1,9 @@
#include "ip_host_protocol_address_information.h"
#include "bits.h"
#ifdef USE_IP
IpHostProtocolAddressInformation::IpHostProtocolAddressInformation(uint8_t* data)
: _data(data)
{}

View File

@ -1,11 +1,13 @@
#include "ip_parameter_object.h"
#ifdef USE_IP
#include "device_object.h"
#include "platform.h"
#include "bits.h"
#include "data_property.h"
#include "callback_property.h"
#ifdef USE_IP
//224.0.23.12
#define DEFAULT_MULTICAST_ADDR ((uint32_t)0xE000170C)

View File

@ -1,4 +1,5 @@
#include "knx_ip_device_information_dib.h"
#include "bits.h"
KnxIpDeviceInformationDIB::KnxIpDeviceInformationDIB(uint8_t* data) : KnxIpDIB(data)

View File

@ -1,4 +1,5 @@
#include "knx_ip_dib.h"
#ifdef USE_IP
KnxIpDIB::KnxIpDIB(uint8_t* data) : _data(data)
{}

View File

@ -1,9 +1,10 @@
#include "knx_ip_frame.h"
#ifdef USE_IP
#include "bits.h"
#include <cstring>
#include "bits.h"
#ifdef USE_IP
#define KNXIP_HEADER_LEN 0x6
#define KNXIP_PROTOCOL_VERSION 0x10

View File

@ -1,4 +1,5 @@
#include "knx_ip_routing_indication.h"
#include <cstring>
#ifdef USE_IP

View File

@ -1,5 +1,7 @@
#include "knx_ip_search_request.h"
#ifdef USE_IP
KnxIpSearchRequest::KnxIpSearchRequest(uint8_t* data, uint16_t length)
: KnxIpFrame(data, length), _hpai(data + LEN_KNXIP_HEADER)
{

View File

@ -1,7 +1,6 @@
#include "knx_ip_search_response.h"
#ifdef USE_IP
#endif
#ifdef USE_IP
#define SERVICE_FAMILIES 2
@ -61,3 +60,4 @@ KnxIpSupportedServiceDIB& KnxIpSearchResponse::supportedServices()
{
return _supportedServices;
}
#endif

View File

@ -1,29 +1,37 @@
#include "memory.h"
#include <string.h>
#include "bits.h"
Memory::Memory(Platform& platform, DeviceObject& deviceObject)
: _platform(platform), _deviceObject(deviceObject)
{
}
{}
Memory::~Memory()
{}
void Memory::readMemory()
{
println("readMemory");
if (_data != nullptr)
uint8_t* flashStart = _platform.getNonVolatileMemoryStart();
size_t flashSize = _platform.getNonVolatileMemorySize();
if (flashStart == nullptr)
{
println("no user flash available;");
return;
}
uint16_t flashSize = 512;
_data = _platform.getEepromBuffer(flashSize);
printHex("RESTORED ", flashStart, _metadataSize);
printHex("RESTORED ", _data, _metadataSize);
//uint16_t metadataBlockSize = alignToPageSize(_metadataSize);
uint16_t metadataBlockSize = _metadataSize;
uint16_t metadataBlockSize = alignToPageSize(_metadataSize);
_freeList = new MemoryBlock(_data + metadataBlockSize, flashSize - metadataBlockSize);
_freeList = new MemoryBlock(flashStart + metadataBlockSize, flashSize - metadataBlockSize);
uint16_t manufacturerId = 0;
const uint8_t* buffer = popWord(manufacturerId, _data);
const uint8_t* buffer = popWord(manufacturerId, flashStart);
uint8_t hardwareType[LEN_HARDWARE_TYPE] = {0};
buffer = popByteArray(hardwareType, LEN_HARDWARE_TYPE, buffer);
@ -58,7 +66,7 @@ void Memory::readMemory()
println(_saveCount);
for (int i = 0; i < _saveCount; i++)
{
println(_data - buffer);
println(flashStart - buffer);
println(".");
buffer = _saveRestores[i]->restore(buffer);
}
@ -67,7 +75,7 @@ void Memory::readMemory()
println(_tableObjCount);
for (int i = 0; i < _tableObjCount; i++)
{
println(_data - buffer);
println(flashStart - buffer);
println(".");
buffer = _tableObjects[i]->restore(buffer);
uint16_t memorySize = 0;
@ -84,29 +92,37 @@ void Memory::readMemory()
void Memory::writeMemory()
{
uint8_t* buffer = _data;
buffer = pushWord(_deviceObject.manufacturerId(), buffer);
buffer = pushByteArray(_deviceObject.hardwareType(), LEN_HARDWARE_TYPE, buffer);
buffer = pushWord(_deviceObject.version(), buffer);
// first get the necessary size of the writeBuffer
size_t writeBufferSize = 16;
for (int i = 0; i < _saveCount; i++)
writeBufferSize = MAX(writeBufferSize, _saveRestores[i]->saveSize());
for (int i = 0; i < _tableObjCount; i++)
writeBufferSize = MAX(writeBufferSize, _tableObjects[i]->saveSize() + 2 /*for memory pos*/);
uint8_t buffer[writeBufferSize];
uint32_t flashPos = 0;
uint8_t* bufferPos = buffer;
bufferPos = pushWord(_deviceObject.manufacturerId(), bufferPos);
bufferPos = pushByteArray(_deviceObject.hardwareType(), LEN_HARDWARE_TYPE, bufferPos);
bufferPos = pushWord(_deviceObject.version(), bufferPos);
flashPos = _platform.writeNonVolatileMemory(flashPos, buffer, bufferPos - buffer);
print("save saveRestores ");
println(_saveCount);
for (int i = 0; i < _saveCount; i++)
{
println(_data - buffer);
println(".");
println((int)_saveRestores[i], HEX);
buffer = _saveRestores[i]->save(buffer);
bufferPos = _saveRestores[i]->save(buffer);
flashPos = _platform.writeNonVolatileMemory(flashPos, buffer, bufferPos - buffer);
}
print("save tableobjs ");
println(_tableObjCount);
for (int i = 0; i < _tableObjCount; i++)
{
println(_data - buffer);
println(".");
println((int)_tableObjects[i], HEX);
buffer = _tableObjects[i]->save(buffer);
bufferPos = _tableObjects[i]->save(buffer);
//save to size of the memoryblock for tableobject too, so that we can rebuild the usedList and freeList
if (_tableObjects[i]->_data != nullptr)
@ -115,17 +131,18 @@ void Memory::writeMemory()
MemoryBlock* block = findBlockInList(_usedList, _tableObjects[i]->_data);
if (block == nullptr)
{
println("_data of TableObject not in errorlist");
println("_data of TableObject not in _usedList");
_platform.fatalError();
}
buffer = pushWord(block->size, buffer);
bufferPos = pushWord(block->size, bufferPos);
}
else
buffer = pushWord(0, buffer);
bufferPos = pushWord(0, bufferPos);
bufferPos = _tableObjects[i]->save(buffer);
}
_platform.commitToEeprom();
printHex("SAVED ", _data, _metadataSize);
_platform.commitNonVolatileMemory();
}
void Memory::addSaveRestore(SaveRestore* obj)
@ -151,8 +168,8 @@ void Memory::addSaveRestore(TableObject* obj)
uint8_t* Memory::allocMemory(size_t size)
{
// always allocate aligned to 32 bit
size = alignToPageSize(size);
// always allocate aligned to pagesize
//size = alignToPageSize(size);
MemoryBlock* freeBlock = _freeList;
MemoryBlock* blockToUse = nullptr;
@ -220,19 +237,19 @@ void Memory::freeMemory(uint8_t* ptr)
void Memory::writeMemory(uint32_t relativeAddress, size_t size, uint8_t* data)
{
memcpy(toAbsolute(relativeAddress), data, size);
_platform.writeNonVolatileMemory(relativeAddress, data, size);
}
uint8_t* Memory::toAbsolute(uint32_t relativeAddress)
{
return _data + (ptrdiff_t)relativeAddress;
return _platform.getNonVolatileMemoryStart() + (ptrdiff_t)relativeAddress;
}
uint32_t Memory::toRelative(uint8_t* absoluteAddress)
{
return absoluteAddress - _data;
return absoluteAddress - _platform.getNonVolatileMemoryStart();
}
MemoryBlock* Memory::removeFromList(MemoryBlock* head, MemoryBlock* item)
@ -352,11 +369,12 @@ void Memory::addToFreeList(MemoryBlock* block)
}
}
uint16_t Memory::alignToPageSize(size_t size)
{
// to 32 bit for now
return (size + 3) & ~0x3;
}
//uint16_t Memory::alignToPageSize(size_t size)
//{
// size_t pageSize = _platform.flashPageSize();
// // pagesize should be a multiply of two
// return (size + pageSize - 1) & (-1*pageSize);
//}
MemoryBlock* Memory::findBlockInList(MemoryBlock* head, uint8_t* address)
{
@ -428,4 +446,4 @@ void Memory::addNewUsedBlock(uint8_t* address, size_t size)
MemoryBlock* newUsedBlock = new MemoryBlock(address, size);
addToUsedList(newUsedBlock);
}
}

View File

@ -24,6 +24,7 @@ class Memory
{
public:
Memory(Platform& platform, DeviceObject& deviceObject);
virtual ~Memory();
void readMemory();
void writeMemory();
void addSaveRestore(SaveRestore* obj);
@ -40,18 +41,22 @@ public:
void addToUsedList(MemoryBlock* block);
void removeFromUsedList(MemoryBlock* block);
void addToFreeList(MemoryBlock* block);
uint16_t alignToPageSize(size_t size);
// uint16_t alignToPageSize(size_t size);
MemoryBlock* removeFromList(MemoryBlock* head, MemoryBlock* item);
MemoryBlock* findBlockInList(MemoryBlock* head, uint8_t* address);
void addNewUsedBlock(uint8_t* address, size_t size);
void readEraseBlockToBuffer(uint32_t blockNum);
uint8_t* eraseBlockStart(uint32_t blockNum);
uint8_t* eraseBlockEnd(uint32_t blockNum);
void saveBufferdEraseBlock();
Platform& _platform;
DeviceObject& _deviceObject;
SaveRestore* _saveRestores[MAXSAVE] = {0};
TableObject* _tableObjects[MAXTABLEOBJ] = {0};
uint8_t _saveCount = 0;
uint8_t _tableObjCount = 0;
uint8_t* _data = nullptr;
MemoryBlock* _freeList = nullptr;
MemoryBlock* _usedList = nullptr;
uint16_t _metadataSize = 0;

View File

@ -1,4 +1,5 @@
#include "network_layer.h"
#include "tpdu.h"
#include "cemi_frame.h"
#include "data_link_layer.h"

View File

@ -1,13 +1,13 @@
#include "npdu.h"
#include "cemi_frame.h"
#include <string.h>
#include "cemi_frame.h"
#include <string.h>
NPDU::NPDU(uint8_t* data, CemiFrame& frame): _data(data), _frame(frame)
{
}
uint8_t NPDU::octetCount() const
{
return _data[0];

View File

@ -1,12 +1,14 @@
#include "platform.h"
#include "bits.h"
#include <cstring>
NvMemoryType Platform::NonVolatileMemoryType()
{
return _memoryType;
}
void Platform::NonVolatileMemoryType(NvMemoryType type)
{
_memoryType = type;
@ -92,3 +94,104 @@ int Platform::readBytesMultiCast(uint8_t *buffer, uint16_t maxLen)
{
return 0;
}
size_t Platform::flashEraseBlockSize()
{
return 0;
}
size_t Platform::flashPageSize()
{
return 0;
}
uint8_t *Platform::userFlashStart()
{
return nullptr;
}
size_t Platform::userFlashSizeEraseBlocks()
{
return 0;
}
void Platform::flashErase(uint16_t eraseBlockNum)
{}
void Platform::flashWritePage(uint16_t pageNumber, uint8_t* data)
{}
uint8_t* Platform::getNonVolatileMemoryStart()
{
return userFlashStart();
}
size_t Platform::getNonVolatileMemorySize()
{
return userFlashSizeEraseBlocks() * flashEraseBlockSize() * flashPageSize();
}
void Platform::commitNonVolatileMemory()
{
}
uint32_t Platform::writeNonVolatileMemory(uint32_t relativeAddress, uint8_t* buffer, size_t size)
{
while (size > 0)
{
loadEraseblockContaining(relativeAddress);
uint32_t start = bufferedEraseBlockStart();
uint32_t end = bufferedEraseBlockEnd();
ptrdiff_t offset = relativeAddress - start;
ptrdiff_t length = end - relativeAddress;
memcpy(_eraseblockBuffer + offset, buffer, length);
_bufferedEraseblockDirty = true;
relativeAddress += length;
buffer += length;
size -= length;
}
return relativeAddress;
}
void Platform::loadEraseblockContaining(uint32_t relativeAddress)
{
int32_t blockNum = getEraseBlockNumberOf(relativeAddress);
if (blockNum < 0)
{
println("loadEraseblockContaining could not get valid eraseblock number");
fatalError();
}
if (blockNum != _bufferedEraseblockNumber)
writeBufferedEraseBlock();
bufferEraseBlock(blockNum);
}
uint32_t Platform::bufferedEraseBlockStart()
{
return _bufferedEraseblockNumber * flashEraseBlockSize();
}
uint32_t Platform::bufferedEraseBlockEnd()
{
return (_bufferedEraseblockNumber + 1) * flashEraseBlockSize() -1;
}
int32_t Platform::getEraseBlockNumberOf(uint32_t relativeAddress)
{
return -1;
}
void Platform::writeBufferedEraseBlock()
{
}
void Platform::bufferEraseBlock(uint32_t eraseBlockNumber)
{
}

View File

@ -46,21 +46,40 @@ class Platform
virtual void setupSpi();
virtual void closeSpi();
virtual int readWriteSpi(uint8_t *data, size_t len);
#if 0
// Flash memory
virtual uint8_t* getNonVolatileMemoryStart();
virtual size_t getNonVolatileMemorySize();
virtual void commitNonVolatileMemory();
// address is relative to start of nonvolatile memory
virtual uint32_t writeNonVolatileMemory(uint32_t relativeAddress, uint8_t* buffer, size_t size);
NvMemoryType NonVolatileMemoryType();
void NonVolatileMemoryType(NvMemoryType type);
protected:
// Flash memory
virtual size_t flashEraseBlockSize(); // in pages
virtual size_t flashPageSize(); // in bytes
virtual uint8_t* userFlashStart(); // start of user flash aligned to start of an erase block
virtual size_t userFlashSizeEraseBlocks(); // in eraseBlocks
virtual void flashErase(uint16_t eraseBlockNum); //relativ to userFlashStart
virtual void flashWritePage(uint16_t pageNumber, uint8_t* data); //write a single page to flash (pageNumber relative to userFashStart
#endif
virtual uint8_t* getEepromBuffer(uint16_t size) = 0;
virtual void commitToEeprom() = 0;
NvMemoryType NonVolatileMemoryType();
void NonVolatileMemoryType(NvMemoryType type);
protected:
NvMemoryType _memoryType = Eeprom;
private:
void loadEraseblockContaining(uint32_t relativeAddress);
uint32_t bufferedEraseBlockStart();
uint32_t bufferedEraseBlockEnd();
int32_t getEraseBlockNumberOf(uint32_t relativeAddress);
void writeBufferedEraseBlock();
void bufferEraseBlock(uint32_t eraseBlockNumber);
// in theory we would have to use this buffer for memory reads too,
// but because ets always restarts the device after programming it
// we can ignore this issue
uint8_t* _eraseblockBuffer = nullptr;
int32_t _bufferedEraseblockNumber = -1;
bool _bufferedEraseblockDirty = false;
};

View File

@ -1,4 +1,5 @@
#include "property.h"
#include "bits.h"
#include <cstring>

View File

@ -1,9 +1,7 @@
#include "config.h"
#ifdef USE_RF
#include "rf_physical_layer.h"
#include "rf_data_link_layer.h"
#include "config.h"
#include "rf_physical_layer.h"
#include "bits.h"
#include "platform.h"
#include "device_object.h"
@ -14,6 +12,8 @@
#include <stdio.h>
#include <string.h>
#ifdef USE_RF
void RfDataLinkLayer::loop()
{
if (!_enabled)

View File

@ -5,6 +5,7 @@
#include <stdint.h>
#include "data_link_layer.h"
#include "rf_physical_layer.h"
#define MAX_KNX_TELEGRAM_SIZE 263

View File

@ -1,8 +1,10 @@
#include <cstring>
#include "rf_medium_object.h"
#include "bits.h"
#include "bits.h"
#include "config.h"
#include <cstring>
#ifdef USE_RF
void RfMediumObject::readProperty(PropertyID propertyId, uint16_t start, uint8_t& count, uint8_t* data)

View File

@ -1,18 +1,14 @@
#include "config.h"
#ifdef USE_RF
#include "rf_physical_layer.h"
#include "rf_data_link_layer.h"
#include "config.h"
#include "rf_data_link_layer.h"
#include "bits.h"
#include "platform.h"
#include <stdio.h>
#include <string.h>
#define MIN(a, b) ((a < b) ? (a) : (b))
#define MAX(a, b) ((a > b) ? (a) : (b))
#define ABS(x) ((x > 0) ? (x) : (-x))
#ifdef USE_RF
// Table for encoding 4-bit data into a 8-bit Manchester encoding.
const uint8_t RfPhysicalLayer::manchEncodeTab[16] = {0xAA, // 0x0 Manchester encoded

View File

@ -1,11 +1,12 @@
#include <string.h>
#include "table_object.h"
#include "bits.h"
#include "memory.h"
#include "callback_property.h"
#include "data_property.h"
#include <string.h>
TableObject::TableObject(Memory& memory)
: _memory(memory)
{}

View File

@ -1,4 +1,5 @@
#include "tpdu.h"
#include "cemi_frame.h"
TPDU::TPDU(uint8_t* data, CemiFrame& frame): _data(data), _frame(frame)

View File

@ -1,5 +1,5 @@
#include "tpuart_data_link_layer.h"
#ifdef USE_TP
#include "bits.h"
#include "platform.h"
#include "device_object.h"
@ -9,6 +9,8 @@
#include <stdio.h>
#include <string.h>
#ifdef USE_TP
// NCN5120
//#define NCN5120

View File

@ -1,10 +1,12 @@
#include "transport_layer.h"
#include "apdu.h"
#include "cemi_frame.h"
#include "network_layer.h"
#include "application_layer.h"
#include "platform.h"
#include "bits.h"
#include <stdio.h>
TransportLayer::TransportLayer(ApplicationLayer& layer, AddressTableObject& gat): _savedFrame(0),

View File

@ -1,5 +1,4 @@
#include "config.h"
#ifdef USE_USB
#include "bits.h"
#include "usb_tunnel_interface.h"
@ -9,7 +8,7 @@
#include <stdio.h>
#include <string.h>
#define MIN(a, b) ((a < b) ? (a) : (b))
#ifdef USE_USB
#define MAX_EP_SIZE 64
#define HID_HEADER_SIZE 3

View File

@ -1,5 +1,15 @@
#include "linux_platform.h"
#ifdef __linux__
#include "knx/device_object.h"
#include "knx/address_table_object.h"
#include "knx/association_table_object.h"
#include "knx/group_object_table_object.h"
#include "knx/application_program_object.h"
#include "knx/ip_parameter_object.h"
#include "knx/bits.h"
#include "knx/ip_host_protocol_address_information.h"
#include <cstdio>
#include <string>
#include <cstring>
@ -27,15 +37,6 @@
#include <poll.h> // Needed for GPIO edge detection
#include <sys/time.h> // Needed for delayMicroseconds()
#include "knx/device_object.h"
#include "knx/address_table_object.h"
#include "knx/association_table_object.h"
#include "knx/group_object_table_object.h"
#include "knx/application_program_object.h"
#include "knx/ip_parameter_object.h"
#include "knx/bits.h"
#include "knx/ip_host_protocol_address_information.h"
#define MAX_MEM 4096
LinuxPlatform::LinuxPlatform()
@ -264,15 +265,15 @@ int LinuxPlatform::readBytesMultiCast(uint8_t* buffer, uint16_t maxLen)
return len;
}
uint8_t* LinuxPlatform::getEepromBuffer(uint16_t size)
uint8_t* LinuxPlatform::getNonVolatileMemoryStart()
{
if (_fd < 0)
doMemoryMapping();
return _mappedFile + 2;
return _mappedFile;
}
void LinuxPlatform::commitToEeprom()
void LinuxPlatform::commitNonVolatileMemory()
{
if (_fd < 0)
doMemoryMapping();
@ -312,8 +313,6 @@ void LinuxPlatform::doMemoryMapping()
if (addr[0] != 0xAF || addr[1] != 0xFE)
{
memset(addr, 0, FLASHSIZE);
addr[0] = 0xAF;
addr[1] = 0xFE;
}
if (addr == MAP_FAILED)

View File

@ -46,8 +46,8 @@ public:
int readWriteSpi (uint8_t *data, size_t len) override;
//memory
uint8_t* getEepromBuffer(uint16_t size) override;
void commitToEeprom() override;
uint8_t* getNonVolatileMemoryStart() override;
void commitNonVolatileMemory() override;
void cmdlineArgs(int argc, char** argv);
private: