diff --git a/.gitignore b/.gitignore index 19477eb..da20bfa 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,8 @@ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ +out +flash.bin # Visual Studio 2015 cache/options directory .vs/ diff --git a/knx-linux/CMakeSettings.json b/knx-linux/CMakeSettings.json new file mode 100644 index 0000000..22985a0 --- /dev/null +++ b/knx-linux/CMakeSettings.json @@ -0,0 +1,19 @@ +{ + "configurations": [ + { + "name": "WSL-Debug", + "generator": "Unix Makefiles", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x64" ], + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [] + } + ] +} \ No newline at end of file diff --git a/knxPython/CMakeSettings.json b/knxPython/CMakeSettings.json new file mode 100644 index 0000000..12fad42 --- /dev/null +++ b/knxPython/CMakeSettings.json @@ -0,0 +1,20 @@ +{ + "configurations": [ + { + "name": "WSL-Debug", + "generator": "Unix Makefiles", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x64" ], + "wslPath": "${defaultWSLPath}", + "addressSanitizerEnabled": true, + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [] + } + ] +} \ No newline at end of file diff --git a/knxPython/knxmodule.cpp b/knxPython/knxmodule.cpp index 4c2b3d2..1051489 100644 --- a/knxPython/knxmodule.cpp +++ b/knxPython/knxmodule.cpp @@ -16,8 +16,8 @@ namespace py = pybind11; #include "knx/bau57B0.h" #include "knx/group_object_table_object.h" -LinuxPlatform platform; -Bau57B0 bau(platform); +LinuxPlatform* platform = 0; +Bau57B0* bau = 0; bool running = false; @@ -25,8 +25,8 @@ static void loop() { while (running) { - bau.loop(); - platform.mdelay(100); + bau->loop(); + platform->mdelay(100); } } @@ -38,10 +38,13 @@ static void Start() if (running) return; + if (!bau) + return; + running = true; - bau.readMemory(); - bau.enabled(true); + bau->readMemory(); + bau->enabled(true); workerThread = std::thread(loop); workerThread.detach(); @@ -53,26 +56,26 @@ static void Stop() return; running = false; - bau.writeMemory(); - bau.enabled(false); + bau->writeMemory(); + bau->enabled(false); workerThread.join(); } static bool ProgramMode(bool value) { - bau.deviceObject().progMode(value); - return bau.deviceObject().progMode(); + bau->deviceObject().progMode(value); + return bau->deviceObject().progMode(); } static bool ProgramMode() { - return bau.deviceObject().progMode(); + return bau->deviceObject().progMode(); } static bool Configured() { - return bau.configured(); + return bau->configured(); } PYBIND11_MAKE_OPAQUE(std::vector); @@ -88,13 +91,12 @@ PYBIND11_MODULE(knx, m) m.def("ProgramMode", (bool(*)())&ProgramMode, "get programing mode active."); m.def("ProgramMode", (bool(*)(bool))&ProgramMode, "Activate / deactivate programing mode."); m.def("Configured", (bool(*)())&Configured, "get configured status."); - m.def("FlashFilePath", []() { return platform.flashFilePath(); }); - m.def("FlashFilePath", [](std::string path) { platform.flashFilePath(path); }); - m.def("GetGroupObject", [](uint16_t goNr) { return bau.groupObjectTable().get(goNr); }); + m.def("FlashFilePath", []() { return platform->flashFilePath(); }); + m.def("FlashFilePath", [](std::string path) { platform->flashFilePath(path); }); + m.def("GetGroupObject", [](uint16_t goNr) { return bau->groupObjectTable().get(goNr); }); py::class_(m, "GroupObject", py::dynamic_attr()) .def(py::init()) - .def("objectWrite", (void(GroupObject::*)(float))&GroupObject::objectWrite) .def("asap", &GroupObject::asap) .def("size", &GroupObject::valueSize) .def_property("value",