public bool sync()
{
if (!this.IsOpen)
{
return false;
}
this.ReadTimeout = 1000;
int f = 0;
while (this.BytesToRead < 1)
{
f++;
System.Threading.Thread.Sleep(1);
if (f > 1000)
return false;
}
int a = 0;
while (a < 10)
{
if (this.BytesToRead >= 2)
{
byte b1 = (byte)this.ReadByte();
byte b2 = (byte)this.ReadByte();
Console.WriteLine("bytes {0:X} {1:X}", b1, b2);
if (b1 == 0x14 && b2 == 0x10)
{
return true;
}
}
Console.WriteLine("btr {0}", this.BytesToRead);
Thread.Sleep(10);
a++;
}
return false;
}