diff --git a/.gitignore b/.gitignore index 4518ef9..712e508 100644 --- a/.gitignore +++ b/.gitignore @@ -14,13 +14,13 @@ /config.status /config.sub /configure -/debian/daliserver.debhelper.log -/debian/daliserver.postinst.debhelper -/debian/daliserver.postrm.debhelper -/debian/daliserver.prerm.debhelper -/debian/daliserver.substvars +/debian/.debhelper/ +/debian/*.debhelper.log +/debian/*.debhelper +/debian/*.substvars /debian/daliserver/ /debian/files +/debian/debhelper-build-stamp /debian/autoreconf.* /debian/.debhelper /depcomp diff --git a/Makefile.am b/Makefile.am index 7ba2513..7fe8340 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,6 @@ docdir = $(datadir)/doc/@PACKAGE@ doc_DATA = README +appstreamdir = $(datadir)/metainfo +appstream_DATA = com.github.onitake.daliserver.metainfo.xml ACLOCAL_AMFLAGS = -I m4 SUBDIRS = lib src test doc perl diff --git a/com.github.onitake.daliserver.metainfo.xml b/com.github.onitake.daliserver.metainfo.xml new file mode 100644 index 0000000..8857e2f --- /dev/null +++ b/com.github.onitake.daliserver.metainfo.xml @@ -0,0 +1,27 @@ + + + com.github.onitake.daliserver + https://github.com/onitake/daliserver + daliserver + Command multiplexing server for Tridonic DALI USB + FSFAP + BSD-2-Clause + +

+ daliserver exposes a DALI (Digital Addressable Lighting Interface) bus + to the local machine by interfacing with the Tridonic DALI USB adapter. +

+

+ Multiple clients can connect to the multiplexer to send commands to and + receive responses from devices connected to the bus. +

+
+ daliserver.service + + System + Electronics + + + usb:v17B5p0020d* + +
diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..8cadc01 --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,6 @@ +# daliserver on Debian + +This package can run multiple daliserver instances through instanced systemd units. + +This is currently accomplished via a helper script and a configuration file in +/etc/default/daliserver. See there for more information. \ No newline at end of file diff --git a/debian/changelog b/debian/changelog index 5d7c6c1..5fa3eed 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +daliserver (0.5) UNRELEASED; urgency=medium + + * Add multiple device support (systemd only) + Thanks to @sde1000 + * Add appstream metadata + * Remove redundant memory allocation in logger + + -- Gregor Riepl Thu, 28 Mar 2024 08:42:21 +0100 + daliserver (0.4) unstable; urgency=medium * Add systemd unit, SysV init script is kept for compatibility diff --git a/debian/control b/debian/control index 583d4f0..525ff83 100644 --- a/debian/control +++ b/debian/control @@ -2,16 +2,14 @@ Source: daliserver Section: net Priority: optional Maintainer: Gregor Riepl -Build-Depends: debhelper (>= 10), - autotools-dev, pkg-config, - libusb-1.0-0-dev -Standards-Version: 3.9.8 +Build-Depends: debhelper (>= 13), pkgconf, libusb-1.0-0-dev +Standards-Version: 4.6.2 Vcs-Git: https://github.com/onitake/daliserver.git Vcs-Browser: https://github.com/onitake/daliserver Package: daliserver Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, lsb-base +Depends: ${shlibs:Depends}, ${misc:Depends} Description: Command multiplexing server for DALI lighting buses Exposes a DALI (Digital Addressable Lighting Interface) bus to the local machine by interfacing with the Tridonic DALI USB adapter. diff --git a/debian/copyright b/debian/copyright index 4be987c..eb24a8a 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,36 +1,37 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Files: * -Copyright: 2010-2018, Gregor Riepl +Copyright: 2010-2024, Gregor Riepl Johannes Wüthrich philippstroehle Stephen Early Robert Niederreiter License: BSD-2-clause -Files: ./m4/ax_require_defined.m4 +Files: m4/ax_require_defined.m4 Copyright: 2014, Mike Frysinger License: FSFAP -Files: ./m4/ax_pthread.m4 +Files: m4/ax_pthread.m4 Copyright: 2008, Steven G. Johnson 2011, Daniel Richard G. License: GPL-3+ -Files: ./m4/ax_append_flag.m4 +Files: m4/ax_append_flag.m4 Copyright: 2008, Guido U. Draheim 2011, Maarten Bosmans License: GPL-3+ -Files: ./m4/ax_cflags_warn_all.m4 +Files: m4/ax_cflags_warn_all.m4 Copyright: 2008, Guido U. Draheim 2010, Rhys Ulerich License: GPL-3+ +Files: com.github.onitake.daliserver.metainfo.xml +Copyright: 2024, Gregor Riepl +License: FSFAP + License: BSD-2-clause - Copyright (c) 2010-2018, Gregor Riepl - All rights reserved. - . Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: . diff --git a/debian/daliserver-start b/debian/daliserver-start new file mode 100755 index 0000000..06a3a32 --- /dev/null +++ b/debian/daliserver-start @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +DEVPATH=/"$(/bin/systemd-escape --unescape ${1})" +BUSNUM=$(cat ${DEVPATH}/busnum) +DEVNUM=$(cat ${DEVPATH}/devnum) +ID_SERIAL_SHORT=$(cat ${DEVPATH}/serial) + +source /etc/default/daliserver + +exec /usr/bin/daliserver $DALISERVER_OPTS -u $BUSNUM:$DEVNUM diff --git a/debian/daliserver.default b/debian/daliserver.default index 19d2e2d..23c92f3 100644 --- a/debian/daliserver.default +++ b/debian/daliserver.default @@ -4,5 +4,11 @@ # -u only map to one specific USB port (will use the first found otherwise) # -l
sets the listening address (use 0.0.0.0 to listen on all interfaces, default=127.0.0.1) # -p changes the TCP port (default=55825) -DALISERVER_OPTS="" +# -f sets the log file name +DALISERVER_OPTS="-f /var/log/daliserver.log" +# Options set based on serial number of DALI USB for -systemd package variant: +case "$ID_SERIAL_SHORT" in +# 000030A1) DALISERVER_OPTS="-p 55826 -f /var/log/daliserver-cellar.log" ;; +# 0000249A) DALISERVER_OPTS="-p 55827 -f /var/log/daliserver-groundfloor.log" ;; +esac diff --git a/debian/daliserver.install b/debian/daliserver.install new file mode 100644 index 0000000..6c6fd5a --- /dev/null +++ b/debian/daliserver.install @@ -0,0 +1 @@ +debian/daliserver-start usr/libexec/daliserver/ diff --git a/debian/daliserver.service b/debian/daliserver.service index 35e3bc7..e69de29 100644 --- a/debian/daliserver.service +++ b/debian/daliserver.service @@ -1,10 +0,0 @@ -[Unit] -Description=DALI USB adapter multiplexer - -[Service] -# see the defaults file for useful options -EnvironmentFile=-/etc/default/daliserver -ExecStart=/usr/bin/daliserver $DALISERVER_OPTS - -[Install] -WantedBy=multi-user.target diff --git a/debian/daliserver.udev b/debian/daliserver.udev new file mode 100644 index 0000000..e7c27ee --- /dev/null +++ b/debian/daliserver.udev @@ -0,0 +1 @@ +SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="17b5", ATTR{idProduct}=="0020", TAG+="systemd", PROGRAM="/bin/systemd-escape -p --template=daliserver@.service %S%p", ENV{SYSTEMD_WANTS}="%c" diff --git a/debian/daliserver@.service b/debian/daliserver@.service new file mode 100644 index 0000000..80c002a --- /dev/null +++ b/debian/daliserver@.service @@ -0,0 +1,7 @@ +[Unit] +Description=Command multiplexing server for Tridonic DALI USB on %i +BindsTo=%i.device +After=%i.device network.target + +[Service] +ExecStart=/usr/libexec/daliserver/daliserver-start %i diff --git a/lib/log.c b/lib/log.c index 2fdf379..a31a887 100644 --- a/lib/log.c +++ b/lib/log.c @@ -64,31 +64,31 @@ void log_vprintf(unsigned int level, const char *format, va_list args) { } else { out = stdout; } - char *datefmt = malloc(32); + char datefmt[40]; #ifdef HAVE_LOCALTIME_R struct tm nowtm; localtime_r(&now, &nowtm); - snprintf(datefmt, 32, "[%d-%02d-%02d %02d:%02d:%02d] ", nowtm.tm_year + 1900, nowtm.tm_mon + 1, nowtm.tm_mday, nowtm.tm_hour, nowtm.tm_min, nowtm.tm_sec); + snprintf(datefmt, sizeof(datefmt), "[%d-%02d-%02d %02d:%02d:%02d] ", nowtm.tm_year + 1900, nowtm.tm_mon + 1, nowtm.tm_mday, nowtm.tm_hour, nowtm.tm_min, nowtm.tm_sec); #else - snprintf(datefmt, 32, "[%ld] ", now); + snprintf(datefmt, sizeof(datefmt), "[%ld] ", now); #endif - char *prefixfmt = NULL; + const char *prefixfmt = NULL; switch (level) { case LOG_LEVEL_FATAL: - prefixfmt = strdup("!!FATAL!! "); + prefixfmt = "!!FATAL!! "; break; case LOG_LEVEL_ERROR: - prefixfmt = strdup("**ERROR** "); + prefixfmt = "**ERROR** "; break; case LOG_LEVEL_WARN: - prefixfmt = strdup("--WARNING-- "); + prefixfmt = "--WARNING-- "; break; case LOG_LEVEL_INFO: - prefixfmt = strdup("INFO "); + prefixfmt = "INFO "; break; case LOG_LEVEL_DEBUG: default: - prefixfmt = strdup(""); + prefixfmt = ""; break; } va_list fileargs; @@ -108,8 +108,6 @@ void log_vprintf(unsigned int level, const char *format, va_list args) { fflush(fp_logfile); va_end(fileargs); } - free(prefixfmt); - free(datefmt); } #ifdef HAVE_VSYSLOG if (level <= loglevel_syslog) {