2014-09-08, 01:03
I have a Samsung TV that I like to control by serial because I don't like the look of little IR transmitters.
Right now I have this:
And it works but often I have to run it 3 or 4 times before the TV responds.
I got this started:
The problem is this will just keep going over and over even if it does read some data. The TV responds with 3 bytes when theres a successful command. Ideally I would like this to keep trying until it gets those three bytes. (03 0c f1) can someone help me make this work the way I want?
Thanks!!!
Right now I have this:
Code:
import time, serial
ser = serial.Serial(port='/dev/ttyUSB0', baudrate=9600, timeout=1)
ser.write("\x08\x22\x00\x00\x00\x00\xd4")
ser.close()
And it works but often I have to run it 3 or 4 times before the TV responds.
I got this started:
Code:
import time, serial
ser = serial.Serial(port='/dev/ttyUSB0', baudrate=9600, timeout=1)
while True:
data = ser.read(3)
if len(data) > 0:
print 'sucess'
sleep(0.5)
print 'Retrying'
ser.write("\x08\x22\x00\x00\x00\x00\xd4")
ser.close()
The problem is this will just keep going over and over even if it does read some data. The TV responds with 3 bytes when theres a successful command. Ideally I would like this to keep trying until it gets those three bytes. (03 0c f1) can someone help me make this work the way I want?
Thanks!!!