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>
|
<PathStyle>Win10LXSS</PathStyle>
|
||||||
</CustomSourceDirectories>
|
</CustomSourceDirectories>
|
||||||
<BuildHost>
|
<BuildHost>
|
||||||
<HostName>Suzail</HostName>
|
<HostName>Immerlund</HostName>
|
||||||
<Transport>SSH</Transport>
|
<Transport>SSH</Transport>
|
||||||
<UserName>tkunze</UserName>
|
<UserName>tkunze</UserName>
|
||||||
</BuildHost>
|
</BuildHost>
|
||||||
<MainSourceTransferCommand>
|
<MainSourceTransferCommand>
|
||||||
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
|
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
|
||||||
<RemoteHost>
|
<RemoteHost>
|
||||||
<HostName>Suzail</HostName>
|
<HostName>Immerlund</HostName>
|
||||||
<Transport>SSH</Transport>
|
<Transport>SSH</Transport>
|
||||||
<UserName>tkunze</UserName>
|
<UserName>tkunze</UserName>
|
||||||
</RemoteHost>
|
</RemoteHost>
|
||||||
@ -55,7 +55,7 @@
|
|||||||
</ToolchainID>
|
</ToolchainID>
|
||||||
<RelativeSourceDirectory>knxPython</RelativeSourceDirectory>
|
<RelativeSourceDirectory>knxPython</RelativeSourceDirectory>
|
||||||
<ConfigurationType>DEBUG</ConfigurationType>
|
<ConfigurationType>DEBUG</ConfigurationType>
|
||||||
<BinaryDirectory>Debug</BinaryDirectory>
|
<BinaryDirectory />
|
||||||
<MakeCommandTemplate>
|
<MakeCommandTemplate>
|
||||||
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
|
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
|
||||||
<RemoteHost>
|
<RemoteHost>
|
||||||
@ -74,6 +74,8 @@
|
|||||||
<Transport>BuiltinShortcut</Transport>
|
<Transport>BuiltinShortcut</Transport>
|
||||||
</RemoteHost>
|
</RemoteHost>
|
||||||
<Command>$(ToolchainCMake)</Command>
|
<Command>$(ToolchainCMake)</Command>
|
||||||
|
<Arguments>.</Arguments>
|
||||||
|
<WorkingDirectory>$(BuildDir)</WorkingDirectory>
|
||||||
<BackgroundMode xsi:nil="true" />
|
<BackgroundMode xsi:nil="true" />
|
||||||
</CMakeCommand>
|
</CMakeCommand>
|
||||||
<UpdateSourcesInCMakeFile>false</UpdateSourcesInCMakeFile>
|
<UpdateSourcesInCMakeFile>false</UpdateSourcesInCMakeFile>
|
||||||
|
@ -80,6 +80,8 @@ PYBIND11_MODULE(knx, m)
|
|||||||
m.def("ProgramMode", (bool(*)(bool))&ProgramMode, "Activate / deactivate programing mode.");
|
m.def("ProgramMode", (bool(*)(bool))&ProgramMode, "Activate / deactivate programing mode.");
|
||||||
m.def("Configured", (bool(*)())&Configured, "get configured status.");
|
m.def("Configured", (bool(*)())&Configured, "get configured status.");
|
||||||
m.def("RegisterGroupObjects", &RegisterGroupObjects);
|
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())
|
py::class_<GroupObject>(m, "GroupObject", py::dynamic_attr())
|
||||||
.def(py::init<uint8_t>())
|
.def(py::init<uint8_t>())
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
LinuxPlatform::LinuxPlatform()
|
LinuxPlatform::LinuxPlatform()
|
||||||
{
|
{
|
||||||
doMemoryMapping();
|
|
||||||
Platform::_memoryReference = (uint8_t*)malloc(MAX_MEM);
|
Platform::_memoryReference = (uint8_t*)malloc(MAX_MEM);
|
||||||
_currentMaxMem = Platform::_memoryReference;
|
_currentMaxMem = Platform::_memoryReference;
|
||||||
}
|
}
|
||||||
@ -204,18 +203,24 @@ int LinuxPlatform::readBytes(uint8_t * buffer, uint16_t maxLen)
|
|||||||
|
|
||||||
uint8_t * LinuxPlatform::getEepromBuffer(uint16_t size)
|
uint8_t * LinuxPlatform::getEepromBuffer(uint16_t size)
|
||||||
{
|
{
|
||||||
|
if (_fd < 0)
|
||||||
|
doMemoryMapping();
|
||||||
|
|
||||||
return _mappedFile + 2;
|
return _mappedFile + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinuxPlatform::commitToEeprom()
|
void LinuxPlatform::commitToEeprom()
|
||||||
{
|
{
|
||||||
|
if (_fd < 0)
|
||||||
|
doMemoryMapping();
|
||||||
|
|
||||||
fsync(_fd);
|
fsync(_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FLASHSIZE 0x10000
|
#define FLASHSIZE 0x10000
|
||||||
void LinuxPlatform::doMemoryMapping()
|
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)
|
if (_fd < 0)
|
||||||
{
|
{
|
||||||
puts("Error in file opening");
|
puts("Error in file opening");
|
||||||
@ -315,3 +320,15 @@ void LinuxPlatform::freeMemory(uint8_t* ptr)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void LinuxPlatform::flashFilePath(const std::string path)
|
||||||
|
{
|
||||||
|
_flashFilePath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string LinuxPlatform::flashFilePath()
|
||||||
|
{
|
||||||
|
return _flashFilePath;
|
||||||
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include "knx/platform.h"
|
#include "knx/platform.h"
|
||||||
|
|
||||||
class LinuxPlatform: public Platform
|
class LinuxPlatform: public Platform
|
||||||
@ -10,6 +11,9 @@ class LinuxPlatform: public Platform
|
|||||||
public:
|
public:
|
||||||
LinuxPlatform();
|
LinuxPlatform();
|
||||||
|
|
||||||
|
std::string flashFilePath();
|
||||||
|
void flashFilePath(const std::string path);
|
||||||
|
|
||||||
// ip stuff
|
// ip stuff
|
||||||
uint32_t currentIpAddress() override;
|
uint32_t currentIpAddress() override;
|
||||||
uint32_t currentSubnetMask() override;
|
uint32_t currentSubnetMask() override;
|
||||||
@ -48,8 +52,9 @@ private:
|
|||||||
int _socketFd = -1;
|
int _socketFd = -1;
|
||||||
void doMemoryMapping();
|
void doMemoryMapping();
|
||||||
uint8_t* _mappedFile;
|
uint8_t* _mappedFile;
|
||||||
int _fd;
|
int _fd = -1;
|
||||||
uint8_t* _currentMaxMem = 0;
|
uint8_t* _currentMaxMem = 0;
|
||||||
|
std::string _flashFilePath = "flash.bin";
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue
Block a user