PDA

View Full Version : 42LG50 RS232 Receive



gravy
December 6th, 2008, 11:50 AM
Hi Guys,

I've been pouring over the forum trying to figure out how to receive rs232 commands back from my LG LCD TV. I've read through some very similar posts but nothing seemed to help.

I can send commands to the TV fine via girder, but I do not receive anything back. I've attached my init.lua and my LGTV.lua

When I use hyperterminal, I can see that the TV is sending back responses:


ka 0 0
response: a 00 NG00x


The "x" is the terminator for the LG's rs232 protocol.

However, in girder, all i ever receive in the LuaConsole is:



Serial: LGTV : Simple Send: 6B 61 20 30 20 31 2F 72 ka 0 1/r
Serial: LGTV : Simple Receive: Data Code: 16384
Serial: LGTV : ERROR: No response to last command


Any thoughts as to what I have wrong in my LGTV.lua?

Rob H
December 7th, 2008, 03:02 AM
You're sending /r rather than \r (ie a carriage return)

gravy
December 7th, 2008, 08:44 AM
Ah good catch Rob. That was a typo that I had fixed prior to uploading.

However, my situation is still the same - I can send commands to the TV and I am controlling it fine via girder, so the send side of my lua script seems to work fine.

I still do not receive any responses back from the TV. (This sample turns the TV on fine. note I renamed the TV id to "1" in this example)



Serial: LGTV : Simple Send: 6B 61 20 31 20 31 0D ka 1 1.
Serial: LGTV : Simple Receive: Data Code: 16384
Serial: LGTV : ERROR: No response to last command

Rob H
December 7th, 2008, 09:07 AM
You also have the ReceiveTerminator set to 'x' - it should be '\r' as well shouldn't it?

Actually it should be '\r\n' I believe.

gravy
December 7th, 2008, 09:36 AM
I tried '\r\n' with no difference in results, Rob.

I think 'x' is the right receive terminator, based on what I see in hyperterminal results, as well as the rs232 manual for this set:

http://www.merrimacs.ca/misc/hyperterm.JPG

From the LG manual:


[Command2][ ][Set ID][ ][OK][Data][x]

OK Acknowledgement
The TV transmits ACK (acknowledgement) based on this format
when receiving normal data. At this time, if the data is
data read mode, it indicates present status data. If the data is
data write mode, it returns the data of the PC computer.
* In this model, TV will not send the status during the standby mode.
* Data Format
[Command 2] : Use as command.
[Set ID] : Use the small character, if set ID is 10, it will send the ‘0’, ‘a’.
[DATA] : Use the small character, if data is 0 x ab, it will send the ‘a’, ‘b’.
[OK] : Use the large character.


I even tried moving to a fixedlength setup with no luck. I wonder what could be different between Hyperterm and Girder's receive methods?! I have the com parameters setup identically.

gravy
December 7th, 2008, 12:17 PM
Update:
I installed a serial port monitor and viewed how the communications are setup differently between hyperterminal and girder.

According to the port monitor, Girder sets up the connection with the following settings:


Baud rate 9600
DTR off
RTS off
Data bits=8, Stop bits=1, Parity=None
Set chars: Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13
Handflow: ControlHandShake=(), FlowReplace=(XOFF_CONTINUE), XonLimit=128, XoffLimit=128
RTS on
DTR on
Purge the serial port: RXCLEAR


When i issue a command, I can see that the TV does not respond with data.

Here is how Hyperterminal looks when it connects to the port:


COM port is opened
In/out queue size 8192/8192
Baud rate 9600
RTS on
DTR on
Data bits=8, Stop bits=1, Parity=None
Set chars: Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13
Handflow: ControlHandShake=(DTR_CONTROL, ERROR_ABORT), FlowReplace=(TRANSMIT_TOGGLE, RTS_CONTROL, XOFF_CONTINUE), XonLimit=80, XoffLimit=200
Set timeouts: ReadInterval=10, ReadTotalTimeoutMultiplier=0, ReadTotalTimeoutConstant=0, WriteTotalTimeoutMultiplier=0, WriteTotalTimeoutConstant=5000

When I send a command via hyperterminal, the port monitor shows that the TV responds!

So the question is... how do I configure girder to establish the connection in the same fashion as hyperterminal!

Rob H
December 8th, 2008, 02:58 AM
This is very strange, I can't think of any reason why you shouldn't be able to receive characters from that port.

Is this a genuine serial port, a USB<->Serial adaptor or something else?

gravy
December 8th, 2008, 09:12 AM
I'm using a USB -> Serial Adapter. (I control about 5 rs232 devices, 4 of them with USB -> Serial adapters, one with a true serial port.)

I'll try using a true serial port tonight as a test - but you'd think if it was a transcoding issue with the dongle, that Hyperterminal wouldn't work either.

gravy
December 9th, 2008, 08:01 AM
Update: There was no difference between using a "real" serial port and a serial->USB converter.

?? I'm stumped. Is there anything further within the init.lua or serial.dll I can use to setup the connection more similarly to hyperterminal? Or are the differences noted by the serial monitor tool just a red herring?

Rob H
December 10th, 2008, 02:15 AM
That's very strange. You say that you've tried CB_FIXEDLENGTH before - what happens if you do that but set the length to 1?

The other possibility is to try Girder 5 to see if that makes a difference I guess.