Wednesday, October 21, 2015

Using PLINK and Batch Files to Control a Smart TV

Editors Note
What do you know - some new content already.  I think I've pulled all I'm going to pull out of the old archive.  There is so much there that holds little relevance for today it just doesn't make sense.  Going forward, new posts will appear as time and opportunity permit.




I had a customer requirement recently to control a 80" television from a small computer plugged into the HDMI port.  The little computer has one solitary USB port, and the television a single TCPIP port.  With a USB to TCP dongle, I was able to connect the computer to the network port for the television. 

The TV in this case is a SHARP AQUOS... a really nice TV if you have $1400 and want a picture the size of a large window. Communicating with it proved to be a challenge but with enough research and trial and error, I figured out what to do (many thanks to the internet and Google Search). 

First, it calls for Putty, the open source telnet client, rather than the basic Windows telnet client.  The former provides the ability to specify "raw" as the protocol, which is essential.  Secondly, I used plink instead of putty, the command line version by the same developer.  From there, I wrote two files for each command: a cmd line command structure, and a command file to send to the TV. 

TVON.BAT: 


plink 169.254.11.133 -P 10002 -raw < plinkTVON.txt 


This command connects to the IP address assigned by the TV for its port.  We use what is called a cross over or null cable - a specially wired network cable, to make the connection without a server between the TV and the computer.  The TV listens for commands on a configurable port number and defaults to 10002.  Using < plinkTVON.txt allows us to pass the content of the text file with the connection. 

plinkTVON.txt 


POWR1___{crlf} 

The SHARP televisions take 8 bit commands with a return code at the end.  The text file allows me to put a carriage return where I show the {crlf} above and so "executes" the command on the television.  Underscores are spaces. 

Now, one thing that puzzled me, I couldn't actually turn on the TV once I sent a POWR0___ command.  As it turns out, you have to send RSPW1___ to tell the TV to remain in a standby state capable of accepting the POWR1____ command.  The documentation does not make this clear and it was by the grace of God and a really random internet posting that I learned about that little bit of undocumented goodness.   

Now, we can schedule the television to turn on and off to save power when it's not being used to show videos and slide shows at the customers place of business.  This makes digital signs and internal communications a lot more configurable and powerful.  There is more to the overall solution that I may have time to discuss later, but this was the difficult part I thought worth sharing. 

No comments:

Post a Comment