Sending rs232 commands to Samsung tv
I am trying to go to xbmcbuntu from windows 7 with event ghost. I have my Samsung tv connected to a usb rs232 adapter. I have the hex commands but not sure how to use them in Ubuntu. All I really need is the on and off commands. And I want my mce power button to only turn the tv on and off. I keep the media center on all the time as its also my file server.
If you are using lirc you can set any button to run any script.
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.)
I assume that I'm using lirc and I have found great guides on that.

I don't know how to send the commands to the tv.


Hex codes to use

PowerOn: 082200000002d6
PowerOff: 082200000001d5

VolumeUp: 082201000100d4
VolumeDown: 082201000200d3
MuteToggle: 082202000000d4
SpeakerOn: 08220c060000c4
SpeakerOff: 08220c060001c3

HDMI1: 08220a000500c7
HDMI2: 08220a000501C6
HDMI3: 08220a000502c5
HDMI4: 08220a000503c4
VGA: 08220a000400c8
Component1: 08220a000300c9
Component2: 08220a000301c8
A\V1: 08220a000100cb
A\V2: 08220a000101ca
S-Video: 08220a000200ca
TVTuner: 08220a000000cc
Send commands to tv? Tvs dont take lirc commands or do they?.... You need to be using CEC? iirc usb rs232 adapter is not cec.. then again maybe you didnt explain yourself properly since none what you posted makes any sense.
lirc can start any executable you like, see irexec.

What he asked makes perfect sense, his TV has an RS232 connector through which commands can be sent over serial protocol.

He wants lirc to trigger an RS232 command to be sent to the TV.

So he needs to write a script to send the command, and get lirc (via irexec) to trigger it.
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.)
Makes sense if you know that tv's can take commands via serial protocol Wink


see perhaps
I read that post already. It's based on windows and a different ir software. That's where I found the hex codes. I am communicating with the TV through a rs232 connection. There is a plug in for the windows program eventghost and I have been using that for over a year. So I know it works. Just not how to do it in Linux.
Oce you've figured out the irexec stuff just write a little batch that does something like this with the source file containing the binary/hex codes
I do a similar thing with my Pioneer TV and a projector I have. I first tried using bash to send the RS-232 codes, but couldn't get the hex codes to send properly. I ended up installing python-serial and use python scripts to send the codes. Here's how:

install python-serial:
sudo apt-get install python-serial

edit keyboard.xml (in your userdata folder) to add what button presses you want and the scripts they should run. Something like:
      <F9 mod="ctrl">RunScript(/home/xbmc/</F9>
      <F10 mod="ctrl">RunScript(/home/xbmc/</F10>

and then put your RS-232 commands in python script scripts like this...
import time, serial
ser = serial.Serial(port='/dev/ttyS0', baudrate=38400, timeout=1)
if "INPS04" in result:
   xbmc.executebuiltin( "PlayerControl(Stop)" )
this script polls the TV to determine the current input and then switches to another one.

So, to turn your TV on your script could be as simple as:
import serial
ser = serial.Serial(port='/dev/ttyS0', baudrate=38400, timeout=1)
Wow good post, even easier than irexec.

I didn't realise that you couple run a script direct from the keymap file like that!
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.)
How would I run that script from CLI? I am trying to test it but not getting anything.
I figured that out but I only list 4 serial ports and they all fail. I have a usb rs232 adapter. I know the whole setup works. It was used for over a year from windows.
Unplug your USB adapter. Then plug it back in. Now type:

The last part of the output should contain the device information you need. It is probably ttyUSB0. Replace ttyS0 in my sample script with that. Also change the speed (38400) to match the port speed of your tv... whatever you wlaere using in windows.

You can also try doing some simple debugging if you can connect a second computer and send a few characters from your htpc to the second computer.
Found the right device. There's no IO errors now but still no response. Can that python script echo the response from the tv when I run it? That way I can see if the tv is responding at all? I don't have a second Computer to use. Nothing has serial ports. And I only have one serial usb adapter.
import time, serial
ser = serial.Serial(port='/dev/ttyUSB0', baudrate=38400, timeout=1)
print result

This will send a command, wait 1/4 second and print the result. My pioneer responds in less than 0.05 seconds; you can decrease the delay later but I set it higher to have a better chance of the response getting received.

Logout Mark Read Team Forum Stats Members Help
Sending rs232 commands to Samsung tv0
This forum uses Lukasz Tkacz MyBB addons.