Any solution for talking to serial port via Python addon?

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
dynamis_dk Offline
Junior Member
Posts: 33
Joined: Aug 2010
Reputation: 0
Post: #1
So during the course of the day I've managed to get a bit of code working to capture the play / stop status and output a result to the log file.

I'm now looking into how (if its possible) to communicate this result to the serial port with a view to having an arduino attached to it.

I've had a quick search and google on the subject but I can't really find anything definitive if this has been done or is possible, just lots of attempts and no real follow up on any failure / sucess.

From a straight python in linux setup it seems pretty straight forward but i would seem there is no build in serial functions within XBMC? Is this right?

Any advice on directions I could investigate?
find quote
Bstrdsmkr Offline
Posting Freak
Posts: 802
Joined: Oct 2010
Reputation: 16
Post: #2
XBMC has a full python interpreter. Anything that will work in your linux install's python will work in xbmc.

I imagine you are looking/have looked at this: http://arduino.cc/playground/Interfacing/Python
Which recommends pySerial. According to the Features list on this page: http://pyserial.sourceforge.net/pyserial.html pySerial is pure puthon, so you can just put it in a script module and require that module in your addon.

For future reference, you can do this even if the lib is not pure python, but you have to include a version for each platform and detect what platform you're running on, then import the correct version.
find quote
dynamis_dk Offline
Junior Member
Posts: 33
Joined: Aug 2010
Reputation: 0
Post: #3
I'll keep investigating then Smile

Basically being a very much a beginner in the world of XBMC addon's / Python I wanted to know if that was any 'don't bother, been tried etc' reasons not to look into it.

If i make any progress I'll post back any useful info I can give. Mainly this project is for my own personal use but having said that I've no issues in sharing everything I learn - just with no warranties anything with work right in any other setup lol
find quote
Bstrdsmkr Offline
Posting Freak
Posts: 802
Joined: Oct 2010
Reputation: 16
Post: #4
Should work beautifully. For all intents and purposes, any python tutorial you find can be applied directly to xbmc (it includes the full standard library). Every xbmc installation also has access to the xbmc modules documented here: http://mirrors.xbmc.org/docs/python-docs/

Really the only difference between xbmc addons and anything else built in python is distribution. XBMC provides a cross-platform distribution system that makes it easy for even the newest user to install a full python program
find quote
dynamis_dk Offline
Junior Member
Posts: 33
Joined: Aug 2010
Reputation: 0
Post: #5
Thanks Bstrdsmkr - exactly the kind of reasurance I was looking for.

Need to set myself up something to monitor the serial port I'm using to make sure its getting the info as required but other than that, I hopeful things are working as I'm getting no errors which I usually take as a plus sign
find quote
jcerecke Offline
Junior Member
Posts: 5
Joined: May 2012
Reputation: 0
Post: #6
I'd be keen on using an addon that gives xbmc status updates over serial! I'm using a teensy++2.0 to turn button presses into keyboard shortcuts. It would be great if I can drive some LEDs based on status, and also if I knew what xbmc was doing I could change the function of the buttons to give me more flexibility. Have you gotten any further with this?
find quote