PDA

View Full Version : Serial plugin and an LG TV w/rs232



robertmyhtpc
May 30th, 2006, 04:41 PM
All
Just hoping for whatever I am missing here. I am trying to communicate to an LG tv using the serial plug in with no sucess. I have made it work with other devices so my system works. Can anyone suggest what the appropriat call would be from Girder. The command the tv is looking for is

[Command1][Command2][ ][Set ID][ ][Data][Cr]

* [Command 1]: First command to control the set. (j,k,m or x)
* [Command 2]: Second command to control the set.
* [Set ID]: You can adjust the set ID to choose desired TV ID
number in Setup menu. Adjustment range is 1 ~
99. When selecting Set ID ‘0’, every connected the
TV is controlled. Set ID is indicated as decimal
(1~99) on menu and as Hexa decimal (0x0~0x63)
on transmission/receiving protocol.
* [DATA]: To transmit command data.
Transmit ‘FF’ data to read status of command.
* [Cr]: Carriage Return
ASCII code ‘0x0D’
* [ ]: ASCII code ‘space (0x20)’

should there be space or something between the commands?

Thanks for any help. I MISS MARK F!!!

Rob H
May 30th, 2006, 04:51 PM
Here's my serial device for an LG LCD TV - model 32LX2R.

Note that you need to use the included init.lua which replaces the normal init.lua

robertmyhtpc
May 30th, 2006, 05:20 PM
where do the the files go? Do I open in notepad and cut and paste them in the device settings and in the command to be sent? If so, which goes where?

Thanks
Robert

robertmyhtpc
May 30th, 2006, 05:24 PM
Have not had the time to migrate yet to 4. If I must to make your solution work, I will. The TV control is very important to me although, Mark F over a year ago assisted in getting my alarm and marantz receiver to work flawlessly. I would rather not change if not necessary

Rob H
May 30th, 2006, 05:37 PM
Oops, sorry, I hadn't spotted that you were using G3.3

It may still be worth reading the source though.

It's been a long time since I used G3.3 and longer since I used its serial plugin I'm afraid.


An example of a command is -

power on =

ka 0 1<cr>

where <cr> is a carriage return

Mark F
May 31st, 2006, 08:09 AM
Which parts need to be translated to binary and which don't? Can you post a link to the RS-232 protocol manual?

EDIT: Try these.

The attached .zip file contains a .ini and a .lua file. The .ini should be imported into the serial plugin. Be sure to assign the correct COM port to the new device. The .lua file should be placed in the ...../girder/lua directory.

Once you have done the above, restart Girder and you should be able to use the commands on the LGTV device object. For example:

LGTV:PowerOn()

It must be noted that I stole the commands from the files Rob posted. :)

Mark F
May 31st, 2006, 09:01 AM
OK, The above is broken but I'll fix it. :(

EDIT: A fixed version is attached.

Rob H
May 31st, 2006, 10:05 AM
In case you hadn't worked it out already Mark, the LG TVs only use ASCII

Mark F
May 31st, 2006, 01:17 PM
:)

Thanks Rob. I peeked into the G4 stuff you provided and saw that. The linked G3 .zip file has bin->hex->bin turned off.

I hope it works.

robertmyhtpc
June 5th, 2006, 08:19 PM
Great to hear from you. First off, I hope you and your family are all well!

Thanks so much for your reply. I did try the files but with no luck. My Girder directory does not have a lua folder so I created one. Is that correct?

robertmyhtpc
June 5th, 2006, 08:31 PM
The LG website will not let you copy the link to the manual that has all the serial info necessary.The pdf zipped exceeds forum limit. What is my workaround?

Rob H
June 6th, 2006, 03:24 AM
What model number is it?

Mark F
June 6th, 2006, 08:45 AM
It has been a while since I was doing all of this stuff. I forgot that you will need the LUAEvents plugin to have the LUA directory contents executed at startup in G3. :(

The plugin is available at this link (http://www.promixis.com/download.php?ID=317) and at this link (http://prdownloads.sourceforge.net/girderplugins/LUAEvents.1.0.3.zip?download).

Sorry for the confusion.

robertmyhtpc
June 6th, 2006, 09:03 AM
The tv is a 50PX1D in USA

Rob H
June 6th, 2006, 11:01 AM
I think this is the one :-

http://us.lge.com/download/product/file/1000000649/50PX1D-H_Manual.pdf

robertmyhtpc
June 6th, 2006, 11:42 PM
Rah,

You are correct. That is the manual. Are the commands the same as yours?
and
Mark, the lua folder does not populate within Girder. Should I be looking elsewhere?
Thanks all

Rob H
June 7th, 2006, 04:22 AM
Pretty much the same, yeah. There are some extra commands that I noticed (e.g. something about a pixel orbiter I think - which I assume is intended to avoid burn-in), but they're very close.

Mark F
June 7th, 2006, 08:05 AM
If you don't have a LUA folder off of the main Girder directory, create one and place the .lua file in it. The LUAEvents plugin will run all the *.lua files in that directory when Girder starts. Of course you must download and enable the LUAEvents plugin for this to work. ;)

Twit
June 13th, 2006, 12:40 PM
Just to butt in here:

I had all sorts of problems with my LG Plasma - Marh F & Rah99 helped me out in February.

In Girder 3.3 - Enable Generic Serial plugin.

Plugin Settings:

Parity: None
Word: 8
Stop: 1
Handshaking: None
Baud: 9600

Set Your Com port.

Transmit Message Definitions: Tick Terminator - and insert '0d'
Nothing else is ticked.

In your event: ka 0 1 or ka 0 0 (one is for on the other for off - cant remember which way round)

This works 100% on my LG.

Mind you is suffered for a month only to find that the Plasma was not working. Swopped it out and the new one worked straight away.

Later
Simon

robertmyhtpc
June 15th, 2006, 10:00 PM
Well,

I have installed both the DSC Alarm and LGTV plugin with associated gml files with no luck. I am getting tree correct in the logger file from the LG but no responce from the DSC plug in.
Currently I am using my laptop and it has worked perfectly with 3. I have not unistalled 3 and do not want to. Per the forum they can work on the same machine but not at the same time.
The dsc plug in causes lock ups and system hangs.
I did install the new init file and do not know if that matters. I did not have enough sense to save the default install init file so I can not go back.
I guess it makes most sense to start with the tv.
So, my first question is in 3 you had to send the carriage return in a seperate config. is <cr> correct after the command in 4?
Thanks

Rob H
June 16th, 2006, 04:06 AM
First things first :-

1) Open the Lua console and check for error messages
2) Make sure you have the Generic serial plugin enabled and that you have bound the LG LCD TV device to the correct COM port.

And you can have both G3.3 and G4 running at the same time, providing they're not trying to control the same hardware.

robertmyhtpc
June 16th, 2006, 08:47 AM
Rob,

Is Carriage Return represented by "(space)<cr> after a command?
would ka 0 1 <cr> be an appropriate command for Power off?
Thanks

Rob H
June 16th, 2006, 10:35 AM
No, the plugin is already set up to send a CR after a command.

You should just be able to use LGLCD.PowerOff() to send the off command.

robertmyhtpc
June 16th, 2006, 11:08 AM
Hopefully, I was simply entering the commands incorrectly.

So, I am looking at the plugin you graciously shared.

would input set to component 1 be:

LGLCD.MainInputSelectComponent()

?

And I am curious to know, what the brackets() represent

Thanks so much

Rob H
June 16th, 2006, 11:52 AM
You may have to make some modifications to the plugin - my TV only has one component input, so I have a function there called LGLCD.MainComponent().

This is equivalent to sending the command :-

xb 0 40

It's interesting that there are two different commands that change the main input on your TV ie 'kb' and 'xb'

Edit the lua file for the device and change the Inputs as follows :-



local Inputs = {
DTVAntenna = '00',
DTVCable = '01',
AnalogAntenna = '10',
AnalogCable = '11',
Video = '20',
FrontVideo = '21'
Component1 = '40',
Component2 = '41',
RGBDTV = '50',
RGBPC = '60',
HDMIDVI = '90',
}

You'll need to add functions that select the appropriate inputs e.g.


MainComponent1 = function (self)
self:MainInput('Component1')
end,

MainComponent2 = function (self)
self:MainInput('Component2')
end,


The string that is passed to the MainInput function is the same as the key in the Inputs table.

Hope this helps.

I've just realised that I made a mistake earlier - you should use LGLCD:PowerOff() not LGLCD.PowerOff() ie with a colon not a period.

The brackets are there because this is a Lua function call.

robertmyhtpc
June 16th, 2006, 01:03 PM
Rob,

I do not see in your plugin where the set ID is set to 0 (All TV's) How does the serial command send the ID?

Thanks So Very much.

Rob H
June 16th, 2006, 01:19 PM
That's in the SendProtocol() function which is used (normally indirectly) by all the other functions.

robertmyhtpc
June 16th, 2006, 02:10 PM
Rob,

Can you please take a look at my revised plugin. It has seemingly broken as it is not recognized as a plugin

thanks in advance
Robert

Rob H
June 16th, 2006, 02:40 PM
Oops, my fault!

Add a comma to the end of line 19 ie


FrontVideo = '21',

robertmyhtpc
June 16th, 2006, 10:02 PM
the lua console comes back after launch
Serial: LGE LCD TV : Opened Device: nil Port: 1 Settings: 9600 N 0 8 0
then after command sent
Serial: LGE LCD TV : ERROR: No response to last command
What could I be possibly missing!

I have change the serial cable as well, no luck

This is my command
LGLCD:PowerOff()

Rob H
June 17th, 2006, 04:10 AM
What sort of serial cable is it? You need to use a null modem cable (also known as crossed or reversed cable), which has pin 2 connected to pin 3 and vice versa.

Can you talk to the TV using Hyperterminal?

robertmyhtpc
June 17th, 2006, 02:40 PM
Rob,
I am using a flat cable with the universal ends that can be configured. Yes, Hyperterminal does work. I did get the Girder 3 to work. Wierd thing about Hyperterminal is that You can not turn on the tv because you loose communication with the tv. Girder 3 will turn it on with not problem.

Rob H
June 17th, 2006, 03:16 PM
that should be

ka<space>0<space>1<cr>
I'm not sure why you've not had any success with the plugin though.

What version of Girder is this? I'll have to check that it works with the latest version (I'm still running quite an old version on the HTPC).

robertmyhtpc
June 17th, 2006, 03:41 PM
it was the wrong command I was sending! ka 00 00 works! I was using lglcd:poweroff

Thanks, I will continue checking other commands

Rob H
June 17th, 2006, 05:36 PM
Interesting that you're getting the message :-


Serial: LGE LCD TV : Opened Device: nil Port: 1 Settings: 9600 N 0 8 0

that 'nil' is self.Name which should be 'LGE LCD TV'

Do you get any errors in the Lua console? You may want to try setting LogLevel = 1 instead of 3 to see if you get any further info.

robertmyhtpc
June 17th, 2006, 09:37 PM
Rob
Version is
4.0.411

the Lua Console reports

stack traceback:
...ixis\Girder4\/plugins/serial/LG LCD TVII (32LXR).lua:101: in function <...ixis\Girder4\/plugins/serial/LG LCD TVII (32LXR).lua:93>

on a call for the HDMI input

The trouble here is ironic. The whole reason for my interest in controling the tv via serial is that when turning on the LG TV using ir, there is a delay in which it will receive a second code which is the input code. I use the JP1 project with Radio Shack and One for All remotes. You can program these inexpensive remotes to transmit macros. So, when you press "SAT", it turns on the Marantz receiver, puts input DSS on Turns the TV on and turns the the tv to DVI input. One button does everything. The problem is that it works fine if I was watching Sat last and turn it on later but if I press DVD after turning off after watching Sat, the Sat input for the tv is missed because of a delay in which the LG will accept the input command. What happens is when I do a macro in Girder using the serial command, it locks up the lg tv serial command for a long time. I guess the lg is expecting an acknowledgment of the acknowledgment before accepting the second command. Whatever it is between the IR and Serial, I am sure I can figure out a happy medium. I will pound away some more and try to figure out what I have here. The dilemna I have now, Girder 3 works fine and with 4 serial devices so its hard to justify changing but I know I need to. I work for a software company and know how important it is to stay on the latest platform.

Rob H
June 18th, 2006, 04:23 AM
Post the serial device here again and I'll take a look

robertmyhtpc
June 18th, 2006, 06:46 PM
http://us.lge.com/download/product/f...D-H_Manual.pdf

I am using your LG TV files you graciously posted on this string on
Old May 30th, 2006, 08:50 PM

My code is device is attached with modifications I believe as you suggested

Rob H
June 19th, 2006, 02:50 AM
I meant for you to post the .lua file again with your latest changes.

Do you get any response from the plugin when you try to send a command?

If not can you make sure that you have bound it to the correct COM port - I know that sounds a bit patronising, but I did that very thing yesterday!

robertmyhtpc
June 19th, 2006, 10:34 AM
Patronizing is welcomed and most likely deserved!

But, If the com port was wrong, the TV would not respond to the transmitted command, correct?

The attached files are recent. the init has not been changed. It is the same, ( or should be) as you posted.

Thanks

Rob H
June 19th, 2006, 11:23 AM
Ah, sorry, I hadn't realised that the TV was responding.

Can you expand on the error? You should get more information from the Lua console.

yauyau
January 31st, 2007, 01:07 AM
Is it working now? i m having the same problem, tried sending all variants of ka 0 1<CR> (ascii, hex, ascii+hex) and none of them was working..... could some1 help plz...

macgyver2k
June 1st, 2007, 06:42 AM
hi guys, thank you, after trying about a year to communicate with the lcd over serial if finally got it working with your help.

i mailed the german lge support some time ago, and they said it wouldn' work so i didn't tried it again.

i always received: Serial: LGE LCD TV : ERROR: No response to last command.
i remebered there was a serial option in the hidden menu of the 32lx2r. you have to press the "menu" botton on the remote and on the tv the same time. after 7 seconds a window with the hidden settings appears for about 0.2 seconds. just stop pressing the buttons in the moment the window appers and you're in a hidden menu. if you're too slow a password-field appears.

i went to the system menu and changed the baud-rate to 9600 and the serial-mode to "PC".

i'm so happy it works now, thank you.

macgyver2k
June 1st, 2007, 03:03 PM
hi,

did a quick test-program in c++.

only works with com1, just change it and recompile.

syntax is: lgtv.exe <both command-parameters> <arg1> <arg2>
e.g. lgtv.exe ka 0 0 to switch tv off or lgtv.exe ka 0 1 for on.


here is the source:



#define _CRT_SECURE_NO_WARNINGS
#include "stdafx.h"
#include "windows.h"
#include "iostream"

using namespace std;

DWORD iBytesWritten;
DCB dcb;
int i;
char szBuf[1024];
HANDLE hCom;

int _tmain(int argc, _TCHAR* argv[])
{
hCom = CreateFile ( "com1", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
for ( i = 1; i <= 3; i++ )
{
if ( !argv[i] )
{
cout << "syntax error." << endl;
cout << "syntax is: " << argv[0] << " <command1><command2> <argument1> <argument2> " << endl;
return 0;
}
}
dcb.DCBlength = sizeof(DCB);
GetCommState (hCom, &dcb); // get com setting
dcb.BaudRate = 9600; // baudrate
dcb.ByteSize = 8; // bits
dcb.Parity = NOPARITY; // parity
dcb.StopBits = ONESTOPBIT; // Stopbits
SetCommState (hCom, &dcb); // save

sprintf(szBuf, "%s %s %s\r", argv[1], argv[2], argv[3]); // build string commands - space - argument1 - space - argument 2 - termination
WriteFile (hCom, szBuf, strlen(szBuf), &iBytesWritten, NULL); // send to comport


CloseHandle (hCom); // close comport

cout << "" << endl;
cout << "-------------------" << endl;
cout << "Command sent to TV." << endl;
cout << "-------------------" << endl;

return 0;
}



*edit* sorry, small bugfix, didn't realize that the string could get 8 bytes ;)

Tanguy
November 1st, 2008, 01:32 PM
Thanks :) Just another thing, to wake up the TV.. you need to first send a 0x0D before the command ka 0 1

Data Cable Pinout (Female / Female) For my LG 42LE2R Zf


Connecteur DB9

1 2 3 4 5
9 8 7 6

Cable TV Side (Female) (* Pins Are connected inside the TV, RX/TX to the ICL3232CBNZ chip, look like a Max232)

* 1 Vert VSUP 3.3V From TV
* 2 Rouge RX
* 3 Bleu TX
4 N/A
* 5 Marron Blanc GND

6 Marron
7 Bleu Blanc
8 Rouge Blanc
* 9 Vert Blanc GND

* M GND

Cable PC Side (Female)

1 (also working connected to 1.)
* 2 Bleu RX
* 3 Rouge TX
4
* 5 Marron Blanc GND

6
7
8
9

M

Tanguy
November 1st, 2008, 06:00 PM
Here are all the IR codes i found :



0 P+
1 P-
2 V+
3 V-
4
5
6
7
8 Veille
9 Mute
a Mono/Stereo
b Input Select
c
d #
e Sleep Timer
f Input TV
10 0
11 1
12 2
13 3
14 4
15 5
16 6
17 7
18 8
19 9
1a : Affichage Chaine ?
1b : Info (Chaine / Stereo)
1c #
1d #
1e : Favoris
1f #
20 : Teletext
21 : Zoom Teletext
22 : Mode Teletext
23 #
24 : Mix (Transparence Teletext)
25 #
26 : Time / Range Teletext
27 : Range - Teletext
28 #
29 #
2a : Reveal
2b : Teletext ?
2c #
2d #
2e #
2f #
30 : Fermer Teletext
31 #
32 #
33 #
34 #
35 #
36 #
37 #
38 : ?
39 : ?
3a #
3b #
3c #
3d #
3e #
3f #
40 : Fleche Haut
41 : Fleche Bas
42 : Fleche Gauche / Menu
43 : Fleche Gauche / Menu
44 : Fleche Droite
45 #
46 #
47 :
48 #
49 #
4a #
4b #
4c #
4d : Préréglage Image
4e #
4f #
50 #
51 #
52 : Préréglage Son
53 : Liste des Programmes
54 :
55 :
56 :
57 :
58 #
59 #
5a : AV1
5b : ? Close PIP
5c #
5d #
5e #
5f #
60 : PIP
61 : PIP Input / Blue
62 : PIP Position
63 : Yellow
64 : PIP Size
65 : Hold
66 #
67 #
68 #
69 #
6a #
6b #
6c #
6d #
6e #
6f #
70 : Index
71 : PIP - / RED
72 : PIP + / GREEN
73 #
74 #
75 :
76 : 4:3
77 : 16:9
78 #
79 : ARC
7a #
7b :
7c #
7d #
7e #
7f #
80 #
81 :
82 #
83 #
84 #
85 #
86 #
87 #
88 #
89 #
8a #
8b #
8c #
8d #
8e #
8f #
90 #
91 #
92 #
93 #
94 #
95 :
96 #
97 #
98 : HDMI
99 :
9a :
9b :
9c #
9d #
9e #
9f #
a0 #
a1 #
a2 #
a3 #
a4 #
a5 #
a6 :
a7 #
a8 #
a9 #
aa #
ab #
ac #
ad #
ae #
af :
b0 #
b1 #
b2 #
b3 #
b4 #
b5 #
b6 #
b7 #
b8 #
b9 #
ba #
bb #
bc #
bd #
be #
bf : Component
c0 #
c1 #
c2 #
c3 #
c4 : Power On
c5 : Power Off
c6 : HDMI
c7 #
c8 #
c9 #
ca #
cb #
cc #
cd #
ce #
cf #
d0 : AV2
d1 : AV3
d2 : AV4
d3 : Svideo 2
d4 :
d5 : RGB
d6 : TV
d7 : RGB
d8 :
d9 #
da ?
db ?
dc #
dd #
de #
df #
e0 : Constrast (Fast) +
e1 : Constrast (Fast) -
e2 #
e3 #
e4 :
e5 #
e6 #
e7 #
e8 #
e9 #
ea #
eb #
ec #
ed #
ee #
ef #
f0 #
f1 #
f2 #
f3 #
f4 #
f5 #
f6 #
f7 #
f8 #
f9 #
fa #
fb #
fc #
fd #
fe #