Script output is wrong
#1
I use this python script from my linux setup to get which input is active in my TV from rs232 :
Code:
import serial
ser = serial.Serial('/dev/ttyS0', 9600, 8, serial.PARITY_NONE, serial.STOPBITS_ONE, xonxoff=0, rtscts=0, timeout=1)
inputstatus = "xb 01 FF\r"
ser.write(inputstatus)
status = ser.readline()
print status

If I run the script from terminal output is normal, but when I call it from an xbmc script with subprocess.popen(['/usr/bin/python', '/scriptlocation/script.py']) the output is the status randomly scrambled. I have also tried subprocess.Popen(), os.system(), setting shell=True but all have the same result. I even tried writing the output into a file, the contents of which are wrong too (running it from terminal, file contents are correct). Also, I played with encodings with no effect (probably reading from ttyS0 is already scrambled before I correct the encoding). Printing simple strings works fine, so the problem is somewhere between reading status from ttyS0 and storing it to a variable.

I guess that although I set the interpreter to /usr/bin/python, xbmc uses its own and this produces the wrong output. Is there any way to override the interpreter?

Thanks
Reply
#2
In eden external python is used and I guess that will take a way the difference.
Reply
#3
After many hours, I found where the problem was! I had the script bound to a button both in .lircrc and in xbmc's remote.xml which caused the script to be called twice and messing the input/output of the serial port. But thanks for the answer, anyway!
Reply

Logout Mark Read Team Forum Stats Members Help
Script output is wrong0