Created
February 13, 2019 22:21
-
-
Save pedrosimoes79/615f72f9080be5df20c9bd7ce0d5c9d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO.Ports; | |
using System.Threading; | |
namespace LGTV_BootloaderAccess | |
{ | |
internal class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
var port = new SerialPort("COM2", 115200, Parity.None, 8, StopBits.One); | |
var responded = false; | |
port.DataReceived += (sender, e) => | |
{ | |
var output = port.ReadExisting(); | |
if (output.Contains("#")) | |
{ | |
responded = true; | |
} | |
Console.Write(output); | |
}; | |
port.Open(); | |
var rnd = new Random(); | |
while (true) | |
{ | |
if (responded) | |
{ | |
break; | |
} | |
var buffer = new byte[32]; | |
rnd.NextBytes(buffer); | |
port.Write(buffer, 0, buffer.Length); | |
Thread.Sleep(5); | |
} | |
Console.BackgroundColor = ConsoleColor.Red; | |
Console.ForegroundColor = ConsoleColor.Yellow; | |
Console.WriteLine("OK"); | |
Console.ReadKey(); // Any key to exit | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment