LG Smart TV Emulator From Command Line

lgsmarttvcommandline

If you wonder if there is a way to run or debug your LG Smart TV application outside of LG IDE, lets say from command line (or Ant), I have some good news for you. It took me some time to discover the necessary requirements but thanks to WMIC and some luck I was able to run and debug the app in emulator with the web inspector.

Requirement for this process is to have LG SDK/IDE including Emulator properly installed. Natively LG IDE (eclipse) handles the process of running or debugging the app in emulator pretty smooth. Once you click run or debug button the eclipse starts local server listening on port 8080 (root is c:/*ECLIPSE-WORKSPACE*/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/*PROJECT*/), starts Safari (installed with LG SDK) within a debug perspective and opens an emulator…

All of these steps can be done manualy from command line:

  • lets consider you already have an local server installed, keep in mind that emulator can target your local server at IP 10.0.2.2
  • Web inspector is a javascript application (part of LG SDK) that can remotely listen and debug a html app running in emulator. You can run it as simple as open it in any browser (chrome worked for me)
  • emulator is an executable file that takes some arguments

Run In Emulator

To run the application in emulator use following .bat

SET "SDK_PATH=C:/Program Files (x86)/LG_Smart_TV_SDK"
SET APP_PATH=http://google.com

"%SDK_PATH%/Resources/jre64/launch4j-tmp/LG_Smart_TV_Emulator_2013.exe" ^
-classpath "%SDK_PATH%/LG_Smart_TV_Emulator_2013/LG_Smart_TV_Emulator_2013.exe;.;lib/vboxjmscom_4.1.jar;lib/vboxjmscom_4.2.jar;lib/jacob.jar;lib/commons-compress-1.3.jar;lib/log4j-1.2.16.jar" ^
com.dtvsdk.emul.VmEmulatorManager -b ^
%APP_PATH%

If your OS is 32 bit, replace “jre64” by “jre”.

Debug In Emulator

Prior being able to use web inspector console for debugging javascript, you need to download jWebSocket and run it with proper config.

  1. visit jwebsocket.org and download “Server” version
  2. unzip somewhere on your drive
  3. merge default jWebServer/conf/jWebServer.xml config file with the one from LG_Smart_TV_SDK/Resources/jWebSocket-1.0/conf/jWebServer.xml
  4. run jWebServer
  5. run web inspector
  6. run emulator

It seems to be sufficient to merge following things in default jWebServer.xml file:

for each engine:

<domain>*</domain>

for user with guest role

<loginname>LG_IDE</loginname>
<password>LG_IDE</password>

for user with user role

<loginname>LG_DTV</loginname>
<password>LG_DTV</password>

Now run the jWebServer with following attributes

SET "SDK_PATH=C:/Program Files (x86)/LG_Smart_TV_SDK"
SET "JWEBSOCKET_PATH=c:/Program Files (x86)/jWebSocket/jWebSocket-1.0"

java -jar "%JWEBSOCKET_PATH%/libs/jWebSocketServer-1.0.jar" ^
-home "%JWEBSOCKET_PATH%" ^
-bootstrap "%SDK_PATH%\Resources\jWebSocket-1.0\conf\Resources\bootstrap.xml" ^
-config "%JWEBSOCKET_PATH%\conf\jWebSocket.xml"

To debug the application in emulator using web inspector use:

SET "SDK_PATH=C:/Program Files (x86)/LG_Smart_TV_SDK"
SET APP_PATH=http://10.0.2.2/your/app/index.html

"%SDK_PATH%/Resources/LGInspectorForIDE/NetCast4/inspector.html"

"%SDK_PATH%/Resources/jre64/launch4j-tmp/LG_Smart_TV_Emulator_2013.exe" ^
-classpath "%SDK_PATH%/LG_Smart_TV_Emulator_2013/LG_Smart_TV_Emulator_2013.exe;.;lib/vboxjmscom_4.1.jar;lib/vboxjmscom_4.2.jar;lib/jacob.jar;lib/commons-compress-1.3.jar;lib/log4j-1.2.16.jar" ^
com.dtvsdk.emul.VmEmulatorManager -d ^
%APP_PATH%

Both, inspector and the application running in emulator connects to your jWebSocker server. It means you can remotely debug any website (e.g. google.com) running in emulator with web inspetor. For debugging the app on real TV device it may require some different steps but I will cover that in another blog post.

Where to go from here:

4 comments so far

  1. Ilia Ablamonov June 27, 2013 00:35

    Thank you very much!

    Btw, where did you found that -b key?

  2. Jozef Chúťka June 27, 2013 09:30

    hi Ilia,
    as mentioned in the article, I used WMIC command.
    1. ran original ide
    2. hit debug/release button so it opens the emulator
    3. used WMIC to trace the arguments

  3. sunpietro September 25, 2013 14:30

    I’m looking forward to read about debugging apps on real TV devices.
    For debugging the app on real TV device it may require some different steps but I will cover that in another blog post.

  4. […] my previous post LG Smart TV Emulator From Command Line, here is the process for debugging html apps running on LG device. It should not take more than 5 […]

Leave a comment

Please be polite and on topic. Your e-mail will never be published.