I am trying to use the native python bindings (from http://git.telldus.com/telldus.git) with a Duo on an Excito B3. I ran into problems with the provided callback.py example. I am monitoring a single temperature sensor. The problem appears to be related to the return type of the callback function. When pasted into a python interpreter window, the following code (simplified example based on callback.py) will segfault after it receives and prints one single sensor reading.
Code: Select all
# This code segfaults upon the first sensor event
import telldus
telldus.tdInit()
def event(*args):
print('event:', args)
return True
telldus.tdRegisterRawDeviceEvent(event)
Code: Select all
# This code runs ok
import ctypes
import telldus
telldus.tdInit()
def event(*args):
print('event:', args)
return ctypes.c_int(0)
telldus.tdRegisterRawDeviceEvent(event)
It is kind of hard to figure out how to use the bindings when the example is broken and documentation is sparse. I am thinking ideally the python native bindings should be wrapped in a small layer which prevents the programmer from having to deal at all with ctypes, at least for provided callback functions.
I know there are other python APIs available, but I wanted to also try this one as an "officially supported" API.