knx/src/linux_platform.h

61 lines
1.7 KiB
C
Raw Normal View History

2018-11-07 00:32:36 +01:00
#pragma once
#ifdef __linux__
2019-01-21 21:29:00 +01:00
#include <string>
2018-11-07 00:32:36 +01:00
#include "knx/platform.h"
class LinuxPlatform: public Platform
{
using Platform::_memoryReference;
using Platform::memoryReference;
2018-11-07 00:32:36 +01:00
public:
LinuxPlatform();
2019-01-21 21:29:00 +01:00
std::string flashFilePath();
void flashFilePath(const std::string path);
2018-11-07 00:32:36 +01:00
// ip stuff
2018-12-22 01:55:08 +01:00
uint32_t currentIpAddress() override;
uint32_t currentSubnetMask() override;
uint32_t currentDefaultGateway() override;
void macAddress(uint8_t* addr) override;
2018-11-07 00:32:36 +01:00
// basic stuff
2018-12-22 01:55:08 +01:00
uint32_t millis() override;
void mdelay(uint32_t millis) override;
void restart() override;
void fatalError() override;
2018-11-07 00:32:36 +01:00
//multicast
2018-12-22 01:55:08 +01:00
void setupMultiCast(uint32_t addr, uint16_t port) override;
void closeMultiCast() override;
bool sendBytes(uint8_t* buffer, uint16_t len) override;
int readBytes(uint8_t* buffer, uint16_t maxLen) override;
2018-11-07 00:32:36 +01:00
//uart
2018-12-22 01:55:08 +01:00
void setupUart() override;
void closeUart() override;
int uartAvailable() override;
size_t writeUart(const uint8_t data) override;
size_t writeUart(const uint8_t *buffer, size_t size) override;
int readUart() override;
size_t readBytesUart(uint8_t *buffer, size_t length) override;
2018-11-07 00:32:36 +01:00
//memory
2018-12-22 01:55:08 +01:00
uint8_t* getEepromBuffer(uint16_t size) override;
void commitToEeprom() override;
uint8_t* allocMemory(size_t size) override;
void freeMemory(uint8_t* ptr) override;
2018-11-07 00:32:36 +01:00
private:
uint32_t _multicastAddr;
uint16_t _port;
int _socketFd = -1;
void doMemoryMapping();
uint8_t* _mappedFile;
2019-01-21 21:29:00 +01:00
int _fd = -1;
uint8_t* _currentMaxMem = 0;
2019-01-21 21:29:00 +01:00
std::string _flashFilePath = "flash.bin";
2018-11-07 00:32:36 +01:00
};
#endif