Linux RS232 Samsung TV Control - Python
#1
I have a python script to turn my tv on and off using samsungs eslink serial control.

It works but not overly reliably. Sometimes I have to run the command multiple times to get it to respond. Then the response is not exactly reliable ether. Theres suppose to be 3 bytes returned but I get 4 to 12. If it works I get the three bytes but sometimes mixed into some other data.

Code:
root@livingroom:~# python tvontest.py
ada103010001a6030cf100
root@livingroom:~# python tvontest.py
00030cf100
root@livingroom:~# nano tvontest.py
root@livingroom:~# python tvontest.py
ada103010001a6030cf100
root@livingroom:~# python tvontest.py
030cf10000
root@livingroom:~# python tvontest.py

root@livingroom:~# python tvontest.py

root@livingroom:~# python tvontest.py
030cf100
root@livingroom:~# python tvontest.py
030cf100ada103010001a6ada103010001a6ada103010001
root@livingroom:~# python tvontest.py
030cf100
root@livingroom:~# python tvontest.py
00
root@livingroom:~# python tvontest.py

root@livingroom:~# python tvontest.py
030cf100
root@livingroom:~# ^C
root@livingroom:~# python tvontest.py
ada103010001a6030cf100
root@livingroom:~# python tvontest.py
00030cf100
root@livingroom:~# python tvontest.py
ada103010001a6030cf100
root@livingroom:~# python tvontest.py
00030cf100
root@livingroom:~# python tvon.py
030cff00030cf100

Can someone tell me how I can get the command to repeate until it finds those three bytes? 030cf1 is the three bytes.
Reply
#2
You may want to share the actual python script
Reply
#3
(2014-09-19, 01:19)drivesoslow Wrote: You may want to share the actual python script

Very good point...

Turns the TV on
Code:
import time, serial
ser = serial.Serial(port='/dev/ttyUSB0', baudrate=9600, timeout=2)
ser.write("\x08\x22\x00\x00\x00\x02\xd4")
data = ser.read(24)
print data.encode('hex')
ser.close()

Turns it off
Code:
import time, serial
ser = serial.Serial(port='/dev/ttyUSB0', baudrate=9600, timeout=2)
ser.write("\x08\x22\x00\x00\x00\x01\xd5")
data = ser.read(24)
print data.encode('hex')
ser.close()

This was one attempt I made. But it did not work.
Code:
import time, serial
ser = serial.Serial(port='/dev/ttyUSB0', baudrate=9600, timeout=1)

while True:
    data = ser.read(24)
    if len(data) > 0:
        ser.close()
        print 'sucess'
        break
    sleep(0.5)
    print 'Retrying'
    ser.write("\x08\x22\x00\x00\x00\x00\xd4")
Reply
#4
This wheel seems to have been invented previously

https://github.com/enlavin/exlink
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#5
Theres no documentation and I dont see anything in those thats going to make sure a command is received. I am also not sure how to get those to work. How would I make it only send the cmd.on hex?
Reply
#6
(2014-09-21, 01:49)Jpaytoncfd Wrote: Theres no documentation and I dont see anything in those thats going to make sure a command is received. I am also not sure how to get those to work. How would I make it only send the cmd.on hex?

Well _snd_cmd waits for and analyses a response.

There is a cmd_power_on defined.

I don't have a Samsung TV, just trying to help. May I simply suggest you play with the github code.

PS your code to turn on and off seems to include xD4 and xD5 at the end of the string, the github code doesn't. is this a problem perhaps?

Also note the comments about the turning on doesn't actually work. I don't know if this is a general comment on Samsung TVs, or a problem with this code or what.
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#7
PS again I guess the d4 d5 thing is the checksum which is defined and used in the github code.
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply

Logout Mark Read Team Forum Stats Members Help
RS232 Samsung TV Control - Python0