Tellstick

Today I plugged a TellStick on FreeBSD 8.0-STABLE :
Code:
Mar 22 10:38:50 atx kernel: ugen0.5: <Telldus> at usbus0
Mar 22 10:38:50 atx root: Unknown USB device: vendor 0x1781 product 0x0c30 bus uhub0
Mar 22 10:38:50 atx uhidd[28880]: terminated
So far so good ... I continued with
Code:
svn co http://svn.telldus.se/telldus/trunk/telldus-core
... then
Code:
cd telldus-core
.
Following instructions at TellStick installation - Linux and messing with cmake options, I finally got the code compiled:
Code:
cmake -DBUILD_LIBTELLDUS-CORE=1 -DBUILD_TDTOOL=1 -DBUILD_RFCMD_WITH_LIBFTDI=0 -DBUILD_LIBTELLDUS-CORE_AS_SERVICE=FALSE
, installed:
Code:
make && sudo make install
and actually working:
Code:
sudo tdtool -v 125 -d 16
... dimming a lamp in the terrarium.
It needs:
devel/cmake, devel/libftdi and finally devel/libconfuse.
However, install stage is not clean enough to be packaged yet: I'looking for someone with porting and cmake background to get this cute piece of software properly ported at last.
 
preliminary port Makefile

svn co [url]http://svn.telldus.se/telldus/trunk/telldus-core[/url] --revision 490
mv telldus-core telldus-core-devel
tar czf telldus-core-devel-2.0.900rev490.tar.gz telldus-core-devel
sudo cp telldus-core-devel-2.0.900rev490.tar.gz /usr/ports/distfiles/
telldus-core-devel.shar
Code:
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#       .
#       ./telldus-core-devel
#       ./telldus-core-devel/Makefile
#       ./telldus-core-devel/files
#       ./telldus-core-devel/files/patch-driver_libtelldus-core_SettingsConfuse.cpp.patch
#       ./telldus-core-devel/files/patch-driver_libtelldus-core_CMakeLists.txt.patch
#       ./telldus-core-devel/pkg-plist
#       ./telldus-core-devel/pkg-descr
#
echo c - .
mkdir -p . > /dev/null 2>&1
echo c - ./telldus-core-devel
mkdir -p ./telldus-core-devel > /dev/null 2>&1
echo x - ./telldus-core-devel/Makefile
sed 's/^X//' >./telldus-core-devel/Makefile << '9b6a8544d2b7bbde2f3a0a6ae1ac3b1d'
X# New ports collection makefile for:   telldus-core-devel
X# Date created:        22 march 2010
X# $FreeBSD$
X#
X
XPORTNAME=      telldus-core-devel
XPORTVERSION=   2.0.900rev490
XCATEGORIES=    comms
XMASTER_SITES=  http://download.telldus.se/TellStick/Software/telldus-core/
XMAINTAINER=    nobody
XCOMMENT=       Utilities for a Telldus TellStick.
X
XWRKSRC=      ${WRKDIR}/${PORTNAME}
X
XUSE_CMAKE=yes
XLIB_DEPENDS= ftdi.18:${PORTSDIR}/devel/libftdi
XLIB_DEPENDS+= confuse.0:${PORTSDIR}/devel/libconfuse
X
XSTATEDIR?=/var/db
X
XCMAKE_ARGS+=   -DBUILD_LIBTELLDUS-CORE=1
XCMAKE_ARGS+=   -DBUILD_TDTOOL=1
XCMAKE_ARGS+=   -DBUILD_RFCMD_WITH_LIBFTDI=0
XCMAKE_ARGS+=   -DBUILD_LIBTELLDUS-CORE_AS_SERVICE=FALSE
XCMAKE_ARGS+=   -DSYSCONF_INSTALL_DIR="${LOCALBASE}/etc"
XCMAKE_ARGS+=   -DSTATE_INSTALL_DIR="${STATEDIR}"
X
X
X.include <bsd.port.mk>
9b6a8544d2b7bbde2f3a0a6ae1ac3b1d
echo c - ./telldus-core-devel/files
mkdir -p ./telldus-core-devel/files > /dev/null 2>&1
echo x - ./telldus-core-devel/files/patch-driver_libtelldus-core_SettingsConfuse.cpp.patch
sed 's/^X//' >./telldus-core-devel/files/patch-driver_libtelldus-core_SettingsConfuse.cpp.patch << 'a3cc0017abb3a1c385a52ff83ae73078'
X--- driver/libtelldus-core/SettingsConfuse.cpp.orig    2010-04-07 05:58:00.000000000 +0200
X+++ driver/libtelldus-core/SettingsConfuse.cpp 2010-04-07 05:58:49.000000000 +0200
X@@ -26,10 +26,11 @@
X bool readConfig(cfg_t **cfg);
X bool readVarConfig(cfg_t **cfg);
X 
X-const char* CONFIG_FILE = "/etc/tellstick.conf";
X #ifdef __FreeBSD__
X-const char* VAR_CONFIG_FILE = "/var/spool/telldus-core.conf";
X+const char* CONFIG_FILE = "/usr/local/etc/tellstick.conf";
X+const char* VAR_CONFIG_FILE = "/var/db/telldus-core.conf";
X #else
X+const char* CONFIG_FILE = "/etc/tellstick.conf";
X const char* VAR_CONFIG_FILE = "/var/state/telldus-core.conf";
X #endif
X 
a3cc0017abb3a1c385a52ff83ae73078
echo x - ./telldus-core-devel/files/patch-driver_libtelldus-core_CMakeLists.txt.patch
sed 's/^X//' >./telldus-core-devel/files/patch-driver_libtelldus-core_CMakeLists.txt.patch << 'c47c7b9287bab09c099b070415e74288'
X--- driver/libtelldus-core/CMakeLists.txt.orig 2010-03-22 17:36:32.000000000 +0100
X+++ driver/libtelldus-core/CMakeLists.txt      2010-03-23 07:15:08.000000000 +0100
X@@ -211,18 +211,19 @@
X ENDIF (UNIX)
X 
X IF (UNIX AND NOT APPLE)
X-      SET(SYSCONF_INSTALL_DIR "/etc" CACHE PATH "The sysconfig install dir (default prefix/etc)" )
X-      SET(STATE_INSTALL_DIR   "/var/state" CACHE PATH "The directory to store state information of the devices" )
X-      SET(UDEV_RULES_DIR      "/etc/udev/rules.d" CACHE PATH "The directory where udev store its rules" )
X+      SET(SYSCONF_INSTALL_DIR "/usr/local/etc" CACHE PATH "The sysconfig install dir (default prefix/etc)" )
X+      SET(STATE_INSTALL_DIR   "/var/db" CACHE PATH "The directory to store state information of the devices" )
X+#     SET(UDEV_RULES_DIR      "/etc/udev/rules.d" CACHE PATH "The directory where udev store its rules" )
X 
X-      INSTALL(FILES tellstick.conf
X+      CONFIGURE_FILE(tellstick.conf tellstick.conf.sample COPYONLY)
X+      INSTALL(FILES tellstick.conf.sample
X               DESTINATION ${SYSCONF_INSTALL_DIR}
X       )
X       INSTALL(FILES telldus-core.conf
X               DESTINATION ${STATE_INSTALL_DIR}
X               PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_WRITE
X       )
X-      INSTALL(FILES 99-tellstick.rules
X-              DESTINATION ${UDEV_RULES_DIR}
X-      )
X+#     INSTALL(FILES 99-tellstick.rules
X+#             DESTINATION ${UDEV_RULES_DIR}
X+#     )
X ENDIF (UNIX AND NOT APPLE)
c47c7b9287bab09c099b070415e74288
echo x - ./telldus-core-devel/pkg-plist
sed 's/^X//' >./telldus-core-devel/pkg-plist << '27c9d6033f5188ee01c946b6e173956c'
Xlib/libtelldus-core.so.2.0.900
Xlib/libtelldus-core.so.2
Xlib/libtelldus-core.so
Xinclude/telldus-core.h
Xinclude/telldus-core-service.h
Xetc/tellstick.conf.sample
Xbin/tdtool
Xbin/rfcmd
X%STATEDIR%telldus-core.conf
27c9d6033f5188ee01c946b6e173956c
echo x - ./telldus-core-devel/pkg-descr
sed 's/^X//' >./telldus-core-devel/pkg-descr << '8a8b1c44f9912f46c89d19162e7e8e35'
XTellStick is a USB-connected transmitter allowing users to control remote receivers from the computer. It is the link
Xbetween the computer and the electronics of the home or the office. By supporting most 433.92 MHz wireless
Xreceivers, TellStick offers a flexible solution. Focusing on simplicity ...
8a8b1c44f9912f46c89d19162e7e8e35
exit
 
pat said:
Makefile
Code:
# New ports collection makefile for:   telldus-core
# Date created:        22 march 2010
# $FreeBSD$
#

PORTNAME=       telldus-core
PORTVERSION=    2.0.900rev490
CATEGORIES=     comms
MASTER_SITES=   http://download.telldus.se/TellStick/Software/telldus-core/
MAINTAINER=     ports@FreeBSD.org
COMMENT=        Utilities for a Telldus TellStick.

WRKSRC=      ${WRKDIR}/${PORTNAME}

USE_CMAKE=yes
BUILD_DEPENDS= ${LOCALBASE}/lib/libftdi.so.18:${PORTSDIR}/devel/libftdi
BUILD_DEPENDS+= ${LOCALBASE}/lib/libconfuse.so.0:${PORTSDIR}/devel/libconfuse

Remove ${LOCALBASE}/lib from the above, and convert them to LIB_DEPENDS.

Code:
STATEDIR?=/var/db

CMAKE_ARGS=-DBUILD_LIBTELLDUS-CORE=1 -DBUILD_TDTOOL=1 -DBUILD_RFCMD_WITH_LIBFTDI=0 \
    -DBUILD_LIBTELLDUS-CORE_AS_SERVICE=FALSE \
    -DSYSCONF_INSTALL_DIR="${LOCALBASE}/etc" \
    -DSTATE_INSTALL_DIR="${STATEDIR}"


.include <bsd.port.mk>


Problems:
  • How does one install (in cmake terms) etc/tellstick.conf to etc/tellstick.conf.sample

You patch the cmakefile (or whatever it's called). The general process is along the lines of:
Code:
# cd /usr/ports/category/port
# mkdir files
# make extract
# cd work/source-dir/
# cp cmakefile cmakefile.orig
# ee cmakefile
<edit as needed>
# diff -u cmakefile.orig cmakefile > ../../files/patch-cmakefile

Then you can do a "make clean" and "make patch" to see if the patch works.

  • In driver/libtelldus-core/SettingsConfuse.cpp: telldus-core.conf
    - where should telldus-core.conf go : in /var/db or /var/spool​
    - it's another tellstick.conf, as I understood it was supposed to store devices states​

If these are user-editable config files, they should go under /usr/local/etc. If they are internal config files that the user never sees, then possibly /var/db/telldus or /usr/share/telldus depending on what their purpose is.

  • I wish devd to link /dev/ugen to /dev/tellstick on-the-fly ...
    a simple ln in a devd attach action script should be enough (?)

Have a read through devd.conf(5) and devfs.conf(5). Then run tail -f /var/run/devd.pipe and plug-in then un-plug the device and see what devd outputs. Using that, you can come up with a devd.conf entry to automate things. I believe devd works with config files under /usr/local/etc/ as well.

  • Right now the distfile is a simple svn checkout tarballed

If you are going to maintain this as a port, then you will need to provide a tarball with a version number (a date or svn revision number) that can be hosted either on your own server or on the FreeBSD FTP server. You can't just put in "svn co" commands in the port Makefile. :)

If there are no stable releases yet, perhaps only create a telldus-devel port that you update every couple of weeks. Then, when there's a real, stable release, ask for a repo-copy of the telldus-devel port to telldus, and update that with the release version.
 
telldus-core-devel port

Mickeprag is right of course ... but I'm lazy and lack free time with Baby coming along. svn rev 490 compiles like a charm, making it the ideal candidate for a port draft.
By the way, following Phoenix advises, here is my /usr/local/etc/devd/telldus.conf:
Code:
attach 10 {
        device-name "ugen[0-9]+";
        match "vendor"  "0x1781";
        match "product" "0x0c30";
        action "/bin/ln -fs /dev/$device-name /dev/tellstick";
};
 
pat said:
Mickeprag is right of course ... but I'm lazy and lack free time with Baby coming along. svn rev 490 compiles like a charm, making it the ideal candidate for a port draft.

I agree. Svn revision 490 compiles wonderfully for me aswell. The tarball suggested by Mickeprag does not compile without patches. Would be very pleased if this could be included in ports.

Mickeprag: could you release revision 490 as a tar-ball?
 
trunk revision 509 builds, but with warnings. Please see below:

Code:
svn co http://svn.telldus.se/telldus/trunk/telldus-core
Checked out revision 509.

Code:
# make
[  4%] Building CXX object driver/libtelldus-core/CMakeFiles/telldus-core.dir/SettingsConfuse.cpp.o
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp: In function 'bool readConfig(cfg_t**)':
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:313: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:327: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:327: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:327: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:327: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:327: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:327: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:327: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:343: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:343: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:343: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp: In function 'bool readVarConfig(cfg_t**)':
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:360: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:360: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:360: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:365: warning: deprecated conversion from string constant to 'char*'
 
  • Thanks
Reactions: pat
These warnings should be there in 490 aswell, right?

We are using a C-library (libconfuse) and gcc doesn't like it's makros when building as C++. I am not sure how to fix it.
 
mickeprag said:
We are using a C-library (libconfuse) and gcc doesn't like it's makros when building as C++. I am not sure how to fix it.
How bad would it be to set the
Code:
-Wno-write-strings
gcc flag on a stable release when compiling SettingsConfuse.cpp ?
I'm flirting with the edge of my gcc knowledge here :e
 
Is there a package available by now? I would like to try this on a pfSense gateway. If not I would have to set up a complete development environment for this, just to try it.

René
 
While there is no port yet, this software compiles fine. I just tested v2.1.1.
It requires
  • cmake
  • libftdi
  • libconfuse
  • argp-standalone

When those are present, just fetch the latest tarball, unpack and do
Code:
cmake .
make
make install
The last one as root.

Remember to start telldusd before trying tdtool.
 
Unfortunately, telldus-core 2.1.2 (released on April 3rd, 2014) doesn't compile as easily:
Code:
tingo@kg-v2$ pwd
/home/tingo/work/telldus-core-2.1.2
tingo@kg-v2$ cmake .
-- The C compiler identification is GNU 4.2.1
-- The CXX compiler identification is GNU 4.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/CC
-- Check for working CXX compiler: /usr/bin/CC -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE 
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.28")
-- checking for one of the modules 'libftdi'
-- Found Doxygen: /usr/local/bin/doxygen (found version "1.8.3.1")
CMake Error: File /home/tingo/work/telldus-core-2.1.2/Doxyfile.in does not exist.
CMake Error at CMakeLists.txt:64 (CONFIGURE_FILE):
  configure_file Problem configuring file


-- Configuring incomplete, errors occurred!
I'm no CMake expert, but there are no "Doxyfiles" here:
Code:
tingo@kg-v2$ find . -name '*Doxy*' -print
tingo@kg-v2$
This is on
Code:
tingo@kg-v2$ uname -a
FreeBSD kg-v2.kg4.no 8.4-STABLE FreeBSD 8.4-STABLE #7 r256430: Sun Oct 13 19:43:35 CEST 2013
     root@kg-v2.kg4.no:/usr/obj/usr/src/sys/GENERIC  amd64
Yes, version 2.1.1 compiled fine.
 
I tried on FreeBSD 9.2-RELEASE #0 i386.

cmake . goes fine, but make fails with

Code:
/root/telldus/telldus-core-2.1.2/common/EventHandler_unix.cpp:82: error: integer constant is too large for 'long' type
*** [common/CMakeFiles/TelldusCommon.dir/EventHandler_unix.cpp.o] Error code 1

Perhaps it needs a 64bit system. I need to upgrade my home automation server to try that.
 
@jstrom: the port doesn't build on 10.0-RELEASE.

Errors:
Code:
===>  Building for telldus-core-2.1.2
Scanning dependencies of target TelldusCommon
[  1%] Building CXX object common/CMakeFiles/TelldusCommon.dir/Event.cpp.o
In file included from /usr/ports/comms/telldus-core/work/telldus-core-2.1.2/common/Event.cpp:7:
/usr/ports/comms/telldus-core/work/telldus-core-2.1.2/common/Event.h:35:15: error: no member named 'tr1' in namespace 'std'
        typedef std::tr1::shared_ptr<EventData> EventDataRef;
                ~~~~~^
/usr/ports/comms/telldus-core/work/telldus-core-2.1.2/common/Event.h:35:30: error: expected unqualified-id
        typedef std::tr1::shared_ptr<EventData> EventDataRef;

I am looking into why this happens. This error is removed when
Code:
USE_GCC= yes
is included in the Makefile.

It now stops on:
Code:
[ 15%] Building CXX object common/CMakeFiles/TelldusCommon.dir/Socket_unix.cpp.o
/usr/ports/comms/telldus-core/work/telldus-core-2.1.2/common/Socket_unix.cpp: In member function 'void TelldusCore::Socket::connect(const wstring&)':
/usr/ports/comms/telldus-core/work/telldus-core-2.1.2/common/Socket_unix.cpp:75:8: error: 'strlen' was not declared in this scope
/usr/ports/comms/telldus-core/work/telldus-core-2.1.2/common/Socket_unix.cpp: In member function 'std::wstring TelldusCore::Socket::read(int)':
/usr/ports/comms/telldus-core/work/telldus-core-2.1.2/common/Socket_unix.cpp:113:37: error: 'memset' was not declared in this scope
*** Error code 1

Which can be fixed by including
Code:
#include <cstring>
in common/Socket_unix.cpp and service/ConnectionListener_unix.cpp


Have you submitted your port for inclusion in the ports tree? That is a lot easier than applying your script.
 
Last edited by a moderator:
Hi,

first of, no I have not submitted it yet. Wanted at least _someone_ else to try it before sent of. Thanks for that :) But submission is absolutely planned.

Regarding 10.0 problems, I think a friend of mine had those problems.. he managed to patch it away with some brute force hacking (he's not a programmer), so the result wasn't as clean. But it basically boiled down to some includes which needed adding, and removing "tr1" in some places..

Not too familiar with 10.0 and gcc/clang/C++11 and so on, so I'm not sure how a "proper" code fix for the tr1 issue would look, but surely there must be some way for pre-c11 code (which uses ::tr1) to be compiled using a c11-aware compiler?
 
I added some stuff to my previous post. The errors are gone using a forced GCC compile and two include statements.

It seems to be working.
 
Ah, simple include fix yes. Thanks!

I think it should be able to compile with clang though, if those ::tr1 things are fixed.. GCC is not installed by default on FreeBSD 10 if I've understood correctly? Which means we'd want it to build with clang if possible.
I don't have a system to test on yet, unfortunately :/ Might have soon though.
 
Back
Top