home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Products
IR Server Suite (IRSS)
Control TV via serial cable
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="MTBikerTim" data-source="post: 268152" data-attributes="member: 54432"><p>I finally got something working reliably for this. It's taken me just a little while to get around to it. Here is the code I have currently for it. It's not the best code and I apologise for that now. I'm sure it could be done better too, I'm a noob what can I say.</p><p></p><p>I was going to stick this into a service which calls this at suspend, resume, shutdown and startup. Haven't worked out what to do for screen saver and for when remote buttons are pressed.</p><p></p><p>[CODE]using System;</p><p>using System.Collections.Generic;</p><p>using System.Text;</p><p>using System.IO.Ports;</p><p></p><p>namespace TVControlApp</p><p>{</p><p> public class TVControl</p><p> {</p><p> public static string cmdPowerOff = "ka 01 00" + (char)0x0D;</p><p> public static string cmdPowerOn = "ka 01 01" + (char)0x0D;</p><p> public static string cmdPowerStatus = "ka 01 FF" + (char)0x0D;</p><p> public static string cmdInputRGB = "xb 01 50" + (char)0x0D;</p><p> public static string cmdInputTV = "xb 01 10" + (char)0x0D;</p><p> public static string cmdInputStatus = "xb 01 FF" + (char)0x0D;</p><p> public static string cmdVolumeLevel = "kf 01 FF" + (char)0x0D;</p><p> public static string cmdVolumeUp = "mc 01 02" + (char)0x0D;</p><p> public static string cmdVolumeDown = "mc 01 03" + (char)0x0D;</p><p></p><p></p><p> public TVControl()</p><p> {</p><p> //create an Serial Port object</p><p> }</p><p></p><p> public string Do(string cmd)</p><p> {</p><p> return SendCommand(cmd);</p><p> }</p><p></p><p> private String SendCommand(String Command)</p><p> {</p><p> SerialPort sp = new SerialPort();</p><p> sp.ReadTimeout = 500;</p><p> string ReturnCommand = "";</p><p> </p><p> try</p><p> {</p><p> sp.Open();</p><p> for (int i = 1; i <= 5; i++)</p><p> {</p><p> //write line to serial port</p><p> sp.WriteLine(Command);</p><p> try</p><p> {</p><p> ReturnCommand = sp.ReadLine();</p><p> }</p><p> catch { }</p><p> if (ReturnCommand != "") break;</p><p> }</p><p> }</p><p> catch (System.Exception ex)</p><p> {</p><p> ReturnCommand = ex.Message;</p><p> }</p><p></p><p> try</p><p> {</p><p> sp.Close();</p><p> }</p><p> catch { }</p><p></p><p> return ReturnCommand;</p><p> }</p><p> }</p><p>}[/CODE]</p></blockquote><p></p>
[QUOTE="MTBikerTim, post: 268152, member: 54432"] I finally got something working reliably for this. It's taken me just a little while to get around to it. Here is the code I have currently for it. It's not the best code and I apologise for that now. I'm sure it could be done better too, I'm a noob what can I say. I was going to stick this into a service which calls this at suspend, resume, shutdown and startup. Haven't worked out what to do for screen saver and for when remote buttons are pressed. [CODE]using System; using System.Collections.Generic; using System.Text; using System.IO.Ports; namespace TVControlApp { public class TVControl { public static string cmdPowerOff = "ka 01 00" + (char)0x0D; public static string cmdPowerOn = "ka 01 01" + (char)0x0D; public static string cmdPowerStatus = "ka 01 FF" + (char)0x0D; public static string cmdInputRGB = "xb 01 50" + (char)0x0D; public static string cmdInputTV = "xb 01 10" + (char)0x0D; public static string cmdInputStatus = "xb 01 FF" + (char)0x0D; public static string cmdVolumeLevel = "kf 01 FF" + (char)0x0D; public static string cmdVolumeUp = "mc 01 02" + (char)0x0D; public static string cmdVolumeDown = "mc 01 03" + (char)0x0D; public TVControl() { //create an Serial Port object } public string Do(string cmd) { return SendCommand(cmd); } private String SendCommand(String Command) { SerialPort sp = new SerialPort(); sp.ReadTimeout = 500; string ReturnCommand = ""; try { sp.Open(); for (int i = 1; i <= 5; i++) { //write line to serial port sp.WriteLine(Command); try { ReturnCommand = sp.ReadLine(); } catch { } if (ReturnCommand != "") break; } } catch (System.Exception ex) { ReturnCommand = ex.Message; } try { sp.Close(); } catch { } return ReturnCommand; } } }[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Products
IR Server Suite (IRSS)
Control TV via serial cable
Contact us
RSS
Top
Bottom