add knx.Stop() method

This commit is contained in:
Thomas Kunze 2019-01-21 23:31:53 +01:00
parent 72269b5675
commit 2731d9b487

View File

@ -19,9 +19,11 @@ namespace py = pybind11;
LinuxPlatform platform;
Bau57B0 bau(platform);
bool running = false;
static void loop()
{
while (1)
while (running)
{
bau.loop();
platform.mdelay(100);
@ -30,13 +32,13 @@ static void loop()
static std::thread workerThread;
bool started = false;
static void Start()
{
if (started)
if (running)
return;
started = true;
running = true;
bau.readMemory();
bau.enabled(true);
@ -45,6 +47,18 @@ static void Start()
workerThread.detach();
}
static void Stop()
{
if (!running)
return;
running = false;
bau.writeMemory();
bau.enabled(false);
workerThread.join();
}
static bool ProgramMode(bool value)
{
bau.deviceObject().progMode(value);
@ -76,6 +90,7 @@ PYBIND11_MODULE(knx, m)
py::bind_vector<std::vector<GroupObject>>(m, "GroupObjectList");
m.def("Start", &Start, "Start knx handling thread.");
m.def("Stop", &Start, "Stop knx handling thread.");
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.");