mirror of
https://github.com/thelsing/knx.git
synced 2025-02-18 00:15:28 +01:00
make path of flash.bin configurable
This commit is contained in:
parent
589ac0787d
commit
72269b5675
@ -7,14 +7,14 @@
|
||||
<PathStyle>Win10LXSS</PathStyle>
|
||||
</CustomSourceDirectories>
|
||||
<BuildHost>
|
||||
<HostName>Suzail</HostName>
|
||||
<HostName>Immerlund</HostName>
|
||||
<Transport>SSH</Transport>
|
||||
<UserName>tkunze</UserName>
|
||||
</BuildHost>
|
||||
<MainSourceTransferCommand>
|
||||
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
|
||||
<RemoteHost>
|
||||
<HostName>Suzail</HostName>
|
||||
<HostName>Immerlund</HostName>
|
||||
<Transport>SSH</Transport>
|
||||
<UserName>tkunze</UserName>
|
||||
</RemoteHost>
|
||||
@ -55,7 +55,7 @@
|
||||
</ToolchainID>
|
||||
<RelativeSourceDirectory>knxPython</RelativeSourceDirectory>
|
||||
<ConfigurationType>DEBUG</ConfigurationType>
|
||||
<BinaryDirectory>Debug</BinaryDirectory>
|
||||
<BinaryDirectory />
|
||||
<MakeCommandTemplate>
|
||||
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
|
||||
<RemoteHost>
|
||||
@ -74,6 +74,8 @@
|
||||
<Transport>BuiltinShortcut</Transport>
|
||||
</RemoteHost>
|
||||
<Command>$(ToolchainCMake)</Command>
|
||||
<Arguments>.</Arguments>
|
||||
<WorkingDirectory>$(BuildDir)</WorkingDirectory>
|
||||
<BackgroundMode xsi:nil="true" />
|
||||
</CMakeCommand>
|
||||
<UpdateSourcesInCMakeFile>false</UpdateSourcesInCMakeFile>
|
||||
|
@ -80,6 +80,8 @@ PYBIND11_MODULE(knx, m)
|
||||
m.def("ProgramMode", (bool(*)(bool))&ProgramMode, "Activate / deactivate programing mode.");
|
||||
m.def("Configured", (bool(*)())&Configured, "get configured status.");
|
||||
m.def("RegisterGroupObjects", &RegisterGroupObjects);
|
||||
m.def("FlashFilePath", []() { return platform.flashFilePath(); });
|
||||
m.def("FlashFilePath", [](std::string path) { platform.flashFilePath(path); });
|
||||
|
||||
py::class_<GroupObject>(m, "GroupObject", py::dynamic_attr())
|
||||
.def(py::init<uint8_t>())
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
LinuxPlatform::LinuxPlatform()
|
||||
{
|
||||
doMemoryMapping();
|
||||
Platform::_memoryReference = (uint8_t*)malloc(MAX_MEM);
|
||||
_currentMaxMem = Platform::_memoryReference;
|
||||
}
|
||||
@ -204,18 +203,24 @@ int LinuxPlatform::readBytes(uint8_t * buffer, uint16_t maxLen)
|
||||
|
||||
uint8_t * LinuxPlatform::getEepromBuffer(uint16_t size)
|
||||
{
|
||||
if (_fd < 0)
|
||||
doMemoryMapping();
|
||||
|
||||
return _mappedFile + 2;
|
||||
}
|
||||
|
||||
void LinuxPlatform::commitToEeprom()
|
||||
{
|
||||
if (_fd < 0)
|
||||
doMemoryMapping();
|
||||
|
||||
fsync(_fd);
|
||||
}
|
||||
|
||||
#define FLASHSIZE 0x10000
|
||||
void LinuxPlatform::doMemoryMapping()
|
||||
{
|
||||
_fd = open("flash.bin", O_RDWR | O_CREAT, S_IRWXU | S_IRGRP | S_IROTH);
|
||||
_fd = open(_flashFilePath.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IRGRP | S_IROTH);
|
||||
if (_fd < 0)
|
||||
{
|
||||
puts("Error in file opening");
|
||||
@ -315,3 +320,15 @@ void LinuxPlatform::freeMemory(uint8_t* ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void LinuxPlatform::flashFilePath(const std::string path)
|
||||
{
|
||||
_flashFilePath = path;
|
||||
}
|
||||
|
||||
|
||||
std::string LinuxPlatform::flashFilePath()
|
||||
{
|
||||
return _flashFilePath;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
#include <string>
|
||||
#include "knx/platform.h"
|
||||
|
||||
class LinuxPlatform: public Platform
|
||||
@ -9,6 +10,9 @@ class LinuxPlatform: public Platform
|
||||
using Platform::_memoryReference;
|
||||
public:
|
||||
LinuxPlatform();
|
||||
|
||||
std::string flashFilePath();
|
||||
void flashFilePath(const std::string path);
|
||||
|
||||
// ip stuff
|
||||
uint32_t currentIpAddress() override;
|
||||
@ -48,8 +52,9 @@ private:
|
||||
int _socketFd = -1;
|
||||
void doMemoryMapping();
|
||||
uint8_t* _mappedFile;
|
||||
int _fd;
|
||||
int _fd = -1;
|
||||
uint8_t* _currentMaxMem = 0;
|
||||
std::string _flashFilePath = "flash.bin";
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user