knx/src/linux_platform.h

82 lines
2.2 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"
2019-10-25 16:41:29 +02:00
extern int gpio_direction(int pin, int dir);
extern int gpio_read(int pin);
extern int gpio_write(int pin, int value);
extern int gpio_export(int pin);
extern int gpio_unexport(int pin);
2018-11-07 00:32:36 +01:00
class LinuxPlatform: public Platform
{
public:
2019-08-22 22:57:35 +02:00
LinuxPlatform();
2019-05-31 23:44:03 +02:00
virtual ~LinuxPlatform();
2019-08-22 22:57:35 +02:00
void cmdLineArgs(int argc, char** argv);
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
// basic stuff
2018-12-22 01:55:08 +01:00
void restart() override;
void fatalError() override;
2018-11-07 00:32:36 +01:00
// ip config
uint32_t currentIpAddress() override;
uint32_t currentSubnetMask() override;
uint32_t currentDefaultGateway() override;
void macAddress(uint8_t* data) override;
2019-05-31 23:44:03 +02:00
//multicast
void setupMultiCast(uint32_t addr, uint16_t port) override;
void closeMultiCast() override;
bool sendBytesMultiCast(uint8_t* buffer, uint16_t len) override;
int readBytesMultiCast(uint8_t* buffer, uint16_t maxLen) override;
2019-12-28 00:29:17 +01:00
bool sendBytesUniCast(uint32_t addr, uint16_t port, uint8_t* buffer, uint16_t len) override;
//UART
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;
2019-10-25 16:41:29 +02:00
//spi
void setupSpi() override;
void closeSpi() override;
int readWriteSpi (uint8_t *data, size_t len) override;
2019-05-31 23:44:03 +02:00
//memory
uint8_t* getEepromBuffer(uint16_t size) override;
void commitToEeprom() override;
void cmdlineArgs(int argc, char** argv);
private:
2019-07-15 21:50:04 +02:00
uint32_t _multicastAddr = -1;
uint16_t _multicastPort = -1;
int _multicastSocketFd = -1;
2018-11-07 00:32:36 +01:00
void doMemoryMapping();
2019-07-15 21:50:04 +02:00
uint8_t* _mappedFile = 0;
2019-01-21 21:29:00 +01:00
int _fd = -1;
2019-10-25 16:41:29 +02:00
int _spiFd = -1;
int _uartFd = -1;
2019-01-21 21:29:00 +01:00
std::string _flashFilePath = "flash.bin";
2019-07-15 21:50:04 +02:00
char** _args = 0;
uint8_t _macAddress[6] = {0, 0, 0, 0, 0, 0};
uint32_t _ipAddress = 0;
uint32_t _netmask = 0;
uint32_t _defaultGateway = 0;
2018-11-07 00:32:36 +01:00
};
#endif