Code Monkey home page Code Monkey logo

linknx's Introduction

linknx

C/C++ CI

This repository is a migration of the legacy one hosted on Sourceforge which is now deprecated.

Documentation

Read the wiki pages for detailed information about how to build, install, configure and run linknx.

How to build linknx

The best option is to download a tarball corresponding to a specific version (see links below). Then, run

./configure
make install

If the build finishes with errors, review them carefully. The most common cause is a dependency that is not installed on your system.

If you need to build the latest revision from the master branch (which is neither required nor recommended for standard usage), do not forget to update the GNU build system first.

autoreconf --install

should suffice. Then, run configure and make install as for other versions.

Downloads

Latest stable release (0.0.1.38)

This is the latest version as of today. Unless you know what you are doing, you should use this version. Download a zip of it here. Fixes issue #47.

Old stable release (0.0.1.37)

This is the previous version known as being stable for production. Download a zip of it here. Implements a redesigned computation of next occurrences for periodic tasks. This redesign was initiated by a problem reported and worked around in Pull Request 37. The rework itself was implemented with Pull Request 39.

For a list of all releases, visit this page.

linknx's People

Contributors

2franix avatar ffontaine avatar fraxinas avatar neheb avatar tru7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

linknx's Issues

Add support for 229 and 235 KNX datapoints

Pour info les DPT 229 et 235 ont été introduite dans la version 2.1 du protocole KNX (Janvier 2014).
Il se compose de 6 octets :

  • les 4 premier bytes sont un entier signé 32 bits Active energy measured in the tarif indicated in the field Tariff (13.010) (Wh)
  • le cinquième byte est un entier non signé 8 bits Tarif associated to the energy indicated in the field ActiveElectricalEnergy
  • le sixième byte est un simple binaire 8 bits b0 =0 si Tarif valide b1=0 si Active energy valide le reste est réservé.

(crédit pollux06)
une base de départ le DPT 12.xxx ...

Migrate from MySQL connector to MariaDB connector

Context

The code still makes use of the MySQL connector C to connect to a MySQL or MariaDB database. That works fine but there are now a few things that advocates for a clear migration to the MariaDB connector C instead:

  • MySQL support in Debian was dropped a while ago. MariaDB has a libmariadb-dev-compat package that symlinks /usr/include/mysql->/usr/include/mariadb to make applications such as linknx happy without them knowing they are actually working with MariaDB. The fact that the package is tagged as "compatibility" is not a very nice signal sent to users IMO, especially since Debian is the main distribution that linknx supports on Linux.
  • MariaDB seems to become more and more the de facto standard for MySQL-like databases.
  • The MySQL connector removed its my_bool typedef but the MariaDB connector still has it. Either we stop using this typedef or we move to the MariaDB connector to get rid of the ambiguity.

Steps

  • In configure.ac, replace the MySQL terminology with MariaDB in comments
    • rename --with-mysql to --with-mariadb. That will force users to be aware of this change.
    • replace mysql_config with mariadb_config
  • in persistentstorage.cpp, include mariadb/mysql.h
  • Document the migration in the wiki to explain what steps are expected to migrate (basically nothing).
  • Adjust the installation steps in the wiki if needed to ask users to install a MariaDB client.

incomplete compiler flags

for years it was necessary to manually add some compiler variables for some recent compilers because the outdated configure environment was not able to derive all the necessary parameters for compiling and linking. An example is the mysql support.
I will try to solve that.

Regression in rules in v0.0.1.35 and v0.0.1.36

Version 0.0.1.35 introduced a regression in rules: the default value "on-true" for actionlist's type attribute does not work anymore when importing a XML config. Such actionlist without an explicit type attribute are simply ignored.

This bug is partly fixed in 0.0.1.36: the initial import of such actionlist works again. Unfortunately, hot update with Rule::updateXml contains a duplicate of the bug that is not covered by the fix. As a consequence, updating the config still leads to discarded actionlists that do not have an explicit type attribute.

The workaround is simple: make sure a type attribute is always set.
Replace

<actionlist>
     <action .../>
</actionlist>

with

<actionlist type="on-true">
     <action .../>
</actionlist>

I am currently adding new unit tests to guarantee such regressions do not happen again. Sorry for the inconvenience.

init="request" for object of type "20.102" does not trigger a read group address on the bus at startup

I have the following object declaration:


when I start linknx, it writes a read request on the bus for the first object, but not for the second. If I manually place a read request on the bus using knxtool groupread, the object gets updated correctly by the read response.
I'm using linknx 1.38 with knxd. I look into what linknx writes using knxtool groupsocketlisten.
If somebody can givme a hint on where to look, I can work out a fix to propose.
Thanks
Ste

Unable to start linknx with --daemon from systemd

Hi

I add linknx v0.0.1.33 in my setup (Rasp 3, Debian Jessie, knxd 0.11.9) and use systemd to control linknx start/stop/status. To do so, I add the following service file and performed necessary command (systemctl enable linknx). Everything is fine, except the fact that there is no logfile /var/log/linknx.log.

> more /lib/systemd/system/linknx.service

[Unit]
Description=Linknx Daemon
After=network.target
[Service]
ExecStart=/usr/local/bin/linknx --config=/var/lib/linknx/linknx.xml --pid-file=/var/run/linknx.pid
Restart=on-failure
RestartSec=3
[Install]
WantedBy=multi-user.target

When I add "--daemon=/var/log/linknx.log" in the [Service] section linknx does not start.

When I start linknx manually like this

> /usr/local/bin/linknx --config=/var/lib/linknx/linknx.xml --pid-file=/var/run/linknx.pid --daemon=/var/log/linknx.log

everything is fine again.

So why does linknx controlled by systemd not accept "--daemon=/var/log/linknx.log". What I see in /var/log/linknx.log is

> cat /var/log/linknx.xml

...
2016-10-21 12:00:29 [ INFO] main: Config file loaded: /var/lib/linknx/linknx.xml
2016-10-21 12:00:29 [ INFO] KnxConnection: KnxConnection: Group socket opened. Waiting for messages.
2016-10-21 12:00:30 [ INFO] Services: Stopping services
2016-10-21 12:00:30 [ INFO] KnxConnection: Out of KnxConnection loop.
...
and systemd tells me that Linknx is started

> systemctl status linknx

● linknx.service - Linknx Daemon
Loaded: loaded (/lib/systemd/system/linknx.service; enabled)
Active: inactive (dead) since Fri 2016-10-21 12:00:30 CEST; 2min 42s ago
Process: 9276 ExecStart=/usr/local/bin/linknx --config=/var/lib/linknx/linknx.xml --pid-file=/var/run/linknx.pid --daemon=/var/log/linknx.log (code=exited, status=0/SUCCESS)
Main PID: 9276 (code=exited, status=0/SUCCESS)
Oct 21 12:00:29 raspberrypi systemd[1]: Started Linknx Daemon.

Kind Regards

New rule action that triggers another rule

Hi guys,

This is my second feature request.

For now, there is no way to build rules like "If (conditions...) then (if (conditions...) then do this, else do that) else if (....)".
The only thing we can do is execute "if/on-true" or "if/on-false" actions of a second rule, no matter the state conditions of that second rule. That second rule is not "evaluated".

Would it be possible to create a new type of actions, that would be "evaluate (or trig) another rule" ? With that solution, we will be able to build very nice scenarios... Like :

Rule 1 
    If (condition 1 AND condition 2)
        if-true : "trig rule 2"
            Rule 2 {
                if (condition 3 OR condition 4)
                    if-true : "do something"
                    if-false : "do something else"
            }
        if-false : "trig rule 3"
            Rule 3 {
                if (condition 5)
                    if-true : "do something"
            }
}

Thank you for your attention !
Eric

Integrate with Travis CI

Use Travis to monitor build status on master.
Define a build matrix that exercises multiple configurations.

sunrise and sunset timer fail to schedule at the end of the month (for the first day of the next month)

Hi,
when running the latest version of linknx (compiled yesterday), the sunrise and sunset timer fail to schedule at the end of the month (for the first day of the next month).
This was working in previous versions.

I'll think this is related to the new computation of periodic tasks, somewhere close to line 493 of suncalc.cpp (tryIncreaseClosestGreaterFreeField..), but haven't had time to look closer.

I'll check the next days whether I find the issue and can provide a fix.

But perhaps this is already a known issue?

Regards,
Michael

Example timer coding:

 <rule id="Timer_1" init='false'>
	<condition type="timer" trigger="true">
		<at type='sunset' offset='20m'/>
	</condition>
	<actionlist>
		<action type='set-value' id='Mode.Test1' value='1'/>
	</actionlist>
</rule>

This is what I get at the end of the month:

2020-03-31 20:04:16,734 [ INFO] Rule: Rule: Configuring Timer_1 (active=1)
2020-03-31 20:04:16,734 [ INFO] TimeSpec: 1899-0--1 -1:-1:0 (wdays=0; exception=2)
2020-03-31 20:04:16,734 [ INFO] SolarTimeSpec: sun_rise_set date 2020-3-31
2020-03-31 20:04:16,735 [ INFO] SolarTimeSpec: sun_rise_set returned 19:56
2020-03-31 20:04:16,735 [ INFO] PeriodicTask: No more schedule available
2020-03-31 20:04:16,735 [ INFO] PeriodicTask: Not rescheduled

To compare, this is how the log looks like on other days:

2020-03-30 20:05:07,861 [ INFO] Rule: Rule: Configuring Timer_1 (active=1)
2020-03-30 20:05:07,861 [ INFO] TimeSpec: 1899-0--1 -1:-1:0 (wdays=0; exception=2)
2020-03-30 20:05:07,861 [ INFO] SolarTimeSpec: sun_rise_set date 2020-3-30
2020-03-30 20:05:07,861 [ INFO] SolarTimeSpec: sun_rise_set returned 19:54
2020-03-30 20:05:07,861 [ INFO] SolarTimeSpec: sun_rise_set date 2020-3-31
2020-03-30 20:05:07,861 [ INFO] SolarTimeSpec: sun_rise_set returned 19:56
2020-03-30 20:05:07,861 [ INFO] PeriodicTask: Rescheduled at 2020-3-31 20:16:00 (1585678560)

Library in cpp

Hi I would like to know if there is any library version available instead of standalone package?
I am trying to integrate it with MQTT and a library would be very helpful.

Support missing connection with KNX bus

At least for testing purposes, it would be convenient to be able to run linknx without any connection to the bus. That should work without any performance degradation in comparison with a standard connected instance.
It requires to support XML config without <knxconnection> element. As of 0.0.1.33, linknx does not properly support that (every attempt to communicate with the bus has to wait for a timeout to expire).

A patch for this is already ready. To be committed soon.

compilation fails with gcc6

does not compile on a system with gcc6 like Debian Stretch mainly because of including math.h in src/suncalc.cpp. It succeeds if this is changed to include cmath, but there are many warnings which should be addressed.

Broken build on Github, master branch

The build on github is broken for the following reasons:

  • the VM running the build (Ubuntu 20.04) is setup with libmysqlclient-dev preinstalled. It provides mysql_config, which is enough to trigger the automatic detection of MySQL support
  • MySQL has removed its my_bool typedef (see this bug, I guess)

That causes the MySQL code to be included in the code to compile, and it breaks at build time since my_bool was removed.

I'm still unsure how to best fix that. Options I have in mind:

  • make sure the build matrix includes a build without MySQL / MariaDB whatever happens. Maybe force --without-mysql to be sure
  • replace my_bool in our codebase so that it does not break when using MySQL. I need to better understand what this typedef meant in the past.
  • always use libmariadb-dev-compat instead of MySQL. This compatibility package seems to still provide my_bool.

Create Tag / Release for the project

Hi,

I work on a Yocto (OpenEmbedded) layer to build all KNX tool.
I want to integrate linknx in the project, and I choose to used your version.

With Yocto, this is better if a recipe use a Tag for 2 reasons:

  • A tag don't move, since I need to add checksum in the recipe, this is better
  • Github provide a way to download a release by downloading directly a tar.gz.

So, should you create a tag for the current last version 0.0.1.33, or a new release based on current master if you think last change stable ?

Thanks,
Fabien Proriol

Remove the obsolete linknx.spec file

This file looks like the config for a rpm file. But it has not been maintained since 2011 and looks mostly outdated.
I would vote for its deletion unless someone argues against that.

uncommon directory structure

please omit the main directory linknx and move everything within one level up to support common compiling procedures.

Rules cannot mix if-xxx and on-xxx actionlists

This bug was initially reported here (in French)

Considering the configuration below

<?xml version="1.0" encoding="UTF-8"?>
<config>
	<services>
                <!-- Port does not matter but 1030 is not to mess with a production instance. -->
		<xmlserver port="1030" type="inet"/>
	</services>
	<objects>
		<object gad="1/1/0" id="Object1" init="on" type="1.001">Object1</object>
		<object gad="1/2/0" id="Object2" init="on" type="1.001">Object2</object>
		<object gad="1/3/0" id="Object3" init="on" type="1.001">Object3</object>
		<object gad="1/4/0" id="Object4" init="on" type="1.001">Object4</object>
	</objects>
	<rules>
		<rule id="Rule1" init="eval">
			<condition type="and" trigger="true">
				<condition type="object" id="Object1" value="on" trigger="true"/>
				<condition type="object" id="Object2" value="on" trigger="true"/>
			</condition>
			<actionlist type="on-false">
				<action type="set-value" id="Object3" value="off"/>
			</actionlist>
			<actionlist type="if-false">
				<action type="set-value" id="Object4" value="off"/>
			</actionlist>
		</rule>
	</rules>
</config>

the bug is reproducible by following these steps (use pyknxread.py and pyknxwrite.py to easily read or write object values from a terminal):

  • change Object1's value to off
    pyknxwrite.py -p 1030 Object1 off
    => rule is evaluated as false and both Object3 and Object4 switch to false
> pyknxread.py -p 1030 -R Object
Object1  False
Object2  True
Object3  False
Object4  False
  • change Object3's value back to on
  • change Object2's value to off => rule is still false. Only actionlist "if-false" is expected to be executed, but both are as Object3 is switched off.

Exporting the config to xml shows that both actionlist are merged into a single actionlist "if-false" (noticeable from the debug output of any pyknxread.py command such as pyknxread.py -R .* -v debug -p 1030)

This is because:

  • the StatelessIf{True,False} flags are set whenever one action part of an actionlist if-{true,false} is imported.
  • the actions "if-true" and "on-true" are all stored in the same collection. Same applies for "if-false" and "on-false".

Make CI build matrix more explicit in the way it selects optional features

The current matrix does neither pass any --with-package nor --without-package options when running configure. It simply installs packages corresponding to the optional features and leans on configure to activate optional features if the current configuration makes it possible (e.g. if LUA is present on the machine, then LUA support is switched on).
It is simple to write in the workflow but has a major drawback: we are not sure that a feature is disabled. For example, even if a MariaDB client is not installed, MySQL support is switched on if a MySQL client is installed.

It would be more explicit to use the --with-package/--without-package options to determine if the feature must be active or not.

Compile fails since commit 0512f6d0a07d50df33bfdca22d48360d164922a8

I tried to compile with the 3 new commits but it fails because of some iconv problem

Compiler: gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)

Some unusual output:
configure.ac:13: warning: macro 'AM_ICONV' not found in library
configure.ac:13: error: possibly undefined macro: AM_ICONV
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
./configure: line 4646: AM_ICONV: command not found

objectcontroller.cpp: In static member function ‘static std::__cxx11::string StringObjectValue::transcode(const string&, const string&, const string&)’:
objectcontroller.cpp:2928:2: error: ‘ICONV_CONST’ was not declared in this scope

Do I suddenly miss something in my build environment?

Get rid of pthsem

@jef2000 did you follow knxd development? with release 0.12 knxd was rewritten to get rid of pthsem and use libev instead. Do you see a chance to do the same for linknx to get a chance to get linknx included in Debian distro and provide a long life for your software?
On a side node: libesmtp was obviously abandoned by the author. Would be nice if it could be replaced by a library supporting ssmtp.
How about restarting your development work? There are quite a bunch of people using linknx and who would appreciate further grow.

Compiler warnings on unclean source code

These three compiler warnings are issued:

ObjectTest.cpp: In member function ‘void ObjectTest::testS32Object()’:
ObjectTest.cpp:2657:36: warning: overflow in implicit constant conversion [-Woverflow]
t.setIntValue(-2000000000UL);

XmlServerTest.cpp: In member function ‘virtual void XmlServerTest::setUp()’:
XmlServerTest.cpp:29:51: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
system ("rm -rf /tmp/linknx_unittest_tmp");

XmlServerTest.cpp: In member function ‘int XmlServerTest::createMsgFd(const char_)’:
XmlServerTest.cpp:41:36: warning: ignoring return value of ‘ssize_t write(int, const void_, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
write(fd, msg, strlen(msg));

Move to Github Actions

Replace the Travis integration with Github Actions.

  • use a build matrix similar to the one in Travis
  • make sure PRs require a build to pass
  • replace the build badge in the README.md file

String encoding issues

There are several issues as of v0.0.1.32 with respect to string encoding:

1/ The request below would fail:

 <?xml version="1.0" encoding="UTF-8"?>
<write>
       <object id="StringObject14" value="àbcdéfghîjklmn"/>
</write>

StringObject14 is of type 16.001, which is the datapoint for 14 character strings encoded in latin1 (aka ISO-8859-1)
Note that the XML request is encoded in UTF-8, as mentioned in the header.
The value is 14 characters long and is as a consequence valid.
The problem comes from the code below:

String14ObjectValue::String14ObjectValue(const std::string& value): StringObjectValue(value)
{
    if ( value.length() > 14)
    {
        std::stringstream msg;
        msg << "String14ObjectValue: Bad value (too long): '" << value << "'" << std::endl;
        throw ticpp::Exception(msg.str());
    }
}

std::string::length() returns the length in bytes, not in characters. This is equal to the length in characters for encodings such as ascii or latin-1, but not for all characters in UTF-8. This is the case for "à" in the init value, which is encoded on two bytes in the request.
This sample request would work if it is encoded in latin1 but this is not fully satisfactory as default XML encoding is expected to be UTF8. The issue applies to the config XML too and encoding it in latin1 forbids the initialization of 28.001 objects (UTF-8 strings) with characters that are not encoded on a single byte.

2/ Investigation for 1/ shows that there is a need for transcoding strings.

Enhance rule triggering with rising and falling edges

Hi guys,

I'm new on Github, so I hope I'm doing my feature request on the good place. And I'm not a C++ developper, so I'm not able to make some pull requests. So I'm just giving some "ideas" to make linknx even more better... ;-)

It would be great if the rule's triggers could be more "granular". For now, rules are triggered on each object's values change (for binary values, "off to on" and "on to off"). But it would be great to be able to trig the rules only when the values goes from off to on, or only from on to off.

For example, il my case, I'm doing actions on sunrise and sunset and only if a second condition is true. My trigger is defined on sunrise and sunset. And I would have some actions done if the rule is evaluated as false.
But the fact is that if the sunrise is at 8:03 for example, my rule will be evaluated as true at 8:03 (if my second condition is also true). But, as "sunrise" is my trigger, at 8:04 the "sunrise" condition changes, and the rule is evaluated, and "in-false" or "on-false" actions are started, each time... So, every day, the "false" actions are executed one minute after sunrise/sunset, which is not good.
And there is no way to change that unless changing triggers behavior...

Thank you for your attention !
Eric

Move the wiki from sourceforge to github

It would be cleaner to have everything hosted on github.
Take the opportunity of the move to fix a few formatting issues (I remember most XML samples are not well displayed).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.