public static void FreeRunRead(string port) { AdapterProtocol ap = new AdapterProtocol(port); Task.Run(() => { Console.WriteLine("press any key to cancel..."); Console.ReadKey(); ap.Cancel(); }); try { ap.Open(); while (true) { byte data = ap.GetByte(0); // no timeout Console.WriteLine("0x{0:X2}", data); } } catch (Exception ex) { Console.WriteLine("fatal error: {0}", ex.Message); } finally { Console.WriteLine("closed serial port"); ap.Close(); } }
private void Stop_Button_Click(object sender, RoutedEventArgs e) { ap.Cancel(); Settings.InProgressScreen = string.Empty; StopEmulation(); }
private void Stop_Button_Click(object sender, RoutedEventArgs e) { if (ap != null) { ap.Cancel(); } if (ap != null) { ap.Close(); } StopEmulation(); }