Problem using serial port from Python in XBMC?
#16
I have been looking at this for the last few days, with the aim to control an Arduino (which in turn will control my lights).

But I am currently struggling to get the pyserial library to install correctly. I have tried the current version of pyserial (2.5) and a few older versions hoping they are more comparable with XBMCs python (2.4).

pyserial seems ok, but it always needs extra modules that XBMC does have and those don't want to install properly (ctype for the newer versions of pyserial and win32 for the older versions).

It is frustrating as I can send/receive serial commands from my computers installation of python (python 2.7 and pyserial 2.5) but can't get it to work within XBMC.

So I am sure it is possible, but at the moment I can't quite figure out how to get it all working.

http://forum.xbmc.org/showthread.php?tid=90540
Reply
#17
Targettio Wrote:I have been looking at this for the last few days, with the aim to control an Arduino (which in turn will control my lights).

But I am currently struggling to get the pyserial library to install correctly. I have tried the current version of pyserial (2.5) and a few older versions hoping they are more comparable with XBMCs python (2.4).

pyserial seems ok, but it always needs extra modules that XBMC does have and those don't want to install properly (ctype for the newer versions of pyserial and win32 for the older versions).

It is frustrating as I can send/receive serial commands from my computers installation of python (python 2.7 and pyserial 2.5) but can't get it to work within XBMC.

So I am sure it is possible, but at the moment I can't quite figure out how to get it all working.

http://forum.xbmc.org/showthread.php?tid=90540

I believe Eden will have Python 2.6-2.7 support and since ctypes is available in python versions 2.5 and greater then it shouldn't be a problem when that happens. If you compile your own XBMC, you can do one of two things: Compile with an external python, or use the following patch to include ctypes(builds the same way as script.module.pysqlite)
Reply
#18
Compiling my own XBMC is a little bit of a sledgehammer to crack a nut, but its looking more and more likely to be the only short term solution.

As you say, ctypes is included in python 2.5, which makes XBMC's 2.4.5 version tantalizingly close but no good. If I was better with python I am sure I could get it all working with 2.4 but can't figure it out atm.

Eden nightlys should be available pretty soon, I guess I can hold out until then.
Reply
#19
Give this a try...

http://www.mediafire.com/file/orbccc4a4e...ctypes.zip
Reply
#20
giftie Wrote:Found this in the patch, it might help you out..

ctypes-1.0.2.win32-py2.4.exe http://downloads.sourceforge.net/project...pes/1.0.2/

The installers look at the registry to find an install location, but xbmc's python doesn't have any registry entries RolleyesHuh

Unless there is some way to 'fool' the installer into finding xbmc's python
Reply
#21
I guess my edit did not show up..

I think I have built the proper Windows(32bit as that was the file I downloaded) script.module.

install the usual way for zip file(install from zip file in settings-> addons)

http://www.mediafire.com/file/orbccc4a4e...ctypes.zip
Reply
#22
giftie Wrote:I guess my edit did not show up..

I think I have built the proper Windows(32bit as that was the file I downloaded) script.module.

install the usual way for zip file(install from zip file in settings-> addons)

http://www.mediafire.com/file/orbccc4a4e...ctypes.zip

Sorry you posted while I was typing my reply. I try that, thanks.
Reply
#23
Thanks for the help giftie, but I still get the same error.

So short term I will probably use XBMC addons to call .bat or .py scripts that use window's python/perl/c. This means I have to have a script for everything I want to do (lights on, dim lights, brighten lights, lights off etc) but it is workable.

Long term. hopefully the new version of python in the new version of XBMC will allow me to use pyserial properly.
Reply
#24
Targettio Wrote:Thanks for the help giftie, but I still get the same error.

So short term I will probably use XBMC addons to call .bat or .py scripts that use window's python/perl/c. This means I have to have a script for everything I want to do (lights on, dim lights, brighten lights, lights off etc) but it is workable.

Long term. hopefully the new version of python in the new version of XBMC will allow me to use pyserial properly.

I forgot to mention that you need to add the following to your addon.xml

Code:
<import addon="script.module.ctypes" version="1.0.2"/>
Reply
#25
Ok, I will give that a shot tonight. Thanks again.
Reply
#26
Maybe you should change the approach.
Why dont you create socket daemon outside of xbmc, like a xml-rpc server or RESTful or whatever you like, which will "talk" with serial port.
Yours xbmc addon then can be a xml-rpc client sending commmands to xml-rpc server, and server will handle all the "dirty-job" with serial port.

You can check what modules are bundled in "xbmc python" with:

import sys
print sys.builtin_module_names

Im not sure, but I think that pyserial is not in this list...
Reply
#27
pyserial isn't included in xbmc's python, and neither is some of pyserial's dependencies (which is where I am hitting issues).

I am reluctant to invest a lot of time into creating complex solutions like socket servers, as XBMC controlling my arduino via serial is only intended to be an interim solution. Longer term I want to connect my arduino via ethernet (using json or something).

Also, it looks like xbmc's python is getting turned on its head, so really I am not sure it is worth me taking my further.
Reply

Logout Mark Read Team Forum Stats Members Help
Problem using serial port from Python in XBMC?0