What's the best way to write to the serial port using a rule?

I have a weird issue controlling my TV via the serial binding. I’m using a USB to serial adapter (I hate those things!!!) on a windows 7 machine. For some reason when openhab controls my TV the computer blue screens. It seems like after 3-4 commands the computer blue screens. I tried older drivers, newer drivers, windows drivers, Manufacturer drivers, swapped out the usb to serial converter entirely but nothing helps. The only thing that helps is to not use openhab. If I use putty I can manually send commands to the Tv many time with no blue screen. As a work around I’m using event ghost to control the TV. Openhab sends a MQTT message that event ghost responds to by sending the serial commands to turn the TV on or off. This is working great, but when I switch back to openhab windows blue screens.

I’ve tried not polling the TV at all and reduced commands to only off or on, essentially turning the TV into a monitor (I have a receiver for sound) but it still blue screens. Although I notices that stripping it down this way helped but after a few hours of no activity the very next command results in a blue screen. The only thing I can think of is maybe it’s the way openhab is sending the command to the hardware. Is there a method other than what i’m doing to send commands to the serial port?

“ka 1 01\r”: turns the TV on. “ka” = Power, “1”=TV selection, “01”=ON(“00”=OFF), “\r”=carrage return.
“kf 1 8\r”=Sets volume to 8.

Item Config:

String TV_FamilyRoom_LG "LG TV [%s]" (gFamilyRoomTV) {serial="COM5@9600"}

Rules:

rule "LG TV Power ON"
	when	
		Item TV_FamilyRoom_Power received command ON
	then
		if(TV_FamilyRoom_Power!=ON){
			TV_FamilyRoom_LG.sendCommand("ka 1 01\r")
			Thread::sleep(3000)
			TV_FamilyRoom_LG.sendCommand("kf 1 8\r")
		}
end
rule "LG TV Power OFF"
	when	
		Item TV_FamilyRoom_Power received command OFF
	then
		if(TV_FamilyRoom_Power!=ON){
			TV_FamilyRoom_LG.sendCommand("kf 1 1\r")
			Thread::sleep(3000)
			TV_FamilyRoom_LG.sendCommand("ka 1 00\r")
		}
end

Information from the TV manual:

Communication Parameters
■ Baud rate : 9600 bps (UART)
■ Data length : 8 bits
■ Parity : None
■ Stop bit : 1 bit
■ Communication code : ASCII code
■ Use a crossed (reverse) cable.

Any ideas??

Hi,

currently solving the same issue. LG serial binding is OK, but I`m missing some functions. When I was testing this binding, I had a second computer, which “represents” LG TV and there was serial port capturing. I saw that there is carriage return at the end of command “ka 0 1CR”. The solution is TV_FamilyRoom_LG.sendCommand(“ka 1 01”+"\r") and so on.

Try, working for me.