Skip to content

Instantly share code, notes, and snippets.

@pedrosimoes79
Created February 13, 2019 22:21
Show Gist options
  • Save pedrosimoes79/615f72f9080be5df20c9bd7ce0d5c9d9 to your computer and use it in GitHub Desktop.
Save pedrosimoes79/615f72f9080be5df20c9bd7ce0d5c9d9 to your computer and use it in GitHub Desktop.
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