Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions com.github.onitake.daliserver.metainfo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="service">
<id>com.github.onitake.daliserver</id>
<url type="homepage">https://github.com/onitake/daliserver</url>
<name>daliserver</name>
<summary>Command multiplexing server for Tridonic DALI USB</summary>
<metadata_license>FSFAP</metadata_license>
<project_license>BSD-2-Clause</project_license>
<description>
<p>
daliserver exposes a DALI (Digital Addressable Lighting Interface) bus
to the local machine by interfacing with the Tridonic DALI USB adapter.
</p>
<p>
Multiple clients can connect to the multiplexer to send commands to and
receive responses from devices connected to the bus.
</p>
</description>
<launchable type="service">daliserver.service</launchable>
<categories>
<category>System</category>
<category>Electronics</category>
</categories>
<provides>
<modalias>usb:v17B5p0020d*</modalias>
</provides>
</component>
6 changes: 6 additions & 0 deletions debian/README.Debian
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 9 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -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 <onitake@gmail.com> Thu, 28 Mar 2024 08:42:21 +0100

daliserver (0.4) unstable; urgency=medium

* Add systemd unit, SysV init script is kept for compatibility
Expand Down
8 changes: 3 additions & 5 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ Source: daliserver
Section: net
Priority: optional
Maintainer: Gregor Riepl <onitake@gmail.com>
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.
Expand Down
17 changes: 9 additions & 8 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/

Files: *
Copyright: 2010-2018, Gregor Riepl <onitake@gmail.com>
Copyright: 2010-2024, Gregor Riepl <onitake@gmail.com>
Johannes Wüthrich <johannes@deragent.net>
philippstroehle <philippstroehle@users.noreply.github.com>
Stephen Early <steve@greenend.org.uk>
Robert Niederreiter <office@squarewave.at>
License: BSD-2-clause

Files: ./m4/ax_require_defined.m4
Files: m4/ax_require_defined.m4
Copyright: 2014, Mike Frysinger <vapier@gentoo.org>
License: FSFAP

Files: ./m4/ax_pthread.m4
Files: m4/ax_pthread.m4
Copyright: 2008, Steven G. Johnson <stevenj@alum.mit.edu>
2011, Daniel Richard G. <skunk@iSKUNK.ORG>
License: GPL-3+

Files: ./m4/ax_append_flag.m4
Files: m4/ax_append_flag.m4
Copyright: 2008, Guido U. Draheim <guidod@gmx.de>
2011, Maarten Bosmans <mkbosmans@gmail.com>
License: GPL-3+

Files: ./m4/ax_cflags_warn_all.m4
Files: m4/ax_cflags_warn_all.m4
Copyright: 2008, Guido U. Draheim <guidod@gmx.de>
2010, Rhys Ulerich <rhys.ulerich@gmail.com>
License: GPL-3+

Files: com.github.onitake.daliserver.metainfo.xml
Copyright: 2024, Gregor Riepl <onitake@gmail.com>
License: FSFAP

License: BSD-2-clause
Copyright (c) 2010-2018, Gregor Riepl <onitake@gmail.com>
All rights reserved.
.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
.
Expand Down
12 changes: 12 additions & 0 deletions debian/daliserver-start
Original file line number Diff line number Diff line change
@@ -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
8 changes: 7 additions & 1 deletion debian/daliserver.default
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@
# -u <bus:dev> only map to one specific USB port (will use the first found otherwise)
# -l <address> sets the listening address (use 0.0.0.0 to listen on all interfaces, default=127.0.0.1)
# -p <port> 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
1 change: 1 addition & 0 deletions debian/daliserver.install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
debian/daliserver-start usr/libexec/daliserver/
10 changes: 0 additions & 10 deletions debian/daliserver.service
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions debian/daliserver.udev
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 7 additions & 0 deletions debian/daliserver@.service
Original file line number Diff line number Diff line change
@@ -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
20 changes: 9 additions & 11 deletions lib/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down