protected static void commThreadFunc(object obj) { BtSerialCommMgr mgr = (BtSerialCommMgr)obj; try { while (!shutdownRequested) { string line = mgr.deviceCommDriver.ReadLine(); if (line.Length > 0) { mgr.LineRecievedEvent.Invoke(mgr, line); } else { continue; } } mgr.deviceCommDriver.Close(); } catch (Exception exc) { System.Diagnostics.Debug.WriteLine(exc.ToString()); System.Diagnostics.Debugger.Break(); } }
private static void startRecieveThread(BtSerialCommMgr mgr) { // start the comm thread if (mgr.commThread == null) { ParameterizedThreadStart pts = new ParameterizedThreadStart(commThreadFunc); mgr.commThread = new Thread(pts); mgr.commThread.Start(mgr); Thread.Sleep(100); } }
static void DefautConnectedHandler(BtSerialCommMgr mgr) { if (mgr.connected) { MainPage.ShowText("Connected."); } else { System.Diagnostics.Debugger.Break(); } }
protected static void DefautLineRecievedHandler(BtSerialCommMgr mgr, string line) { try { //System.Diagnostics.Debug.WriteLine("Line Recieved: " + line); mgr.lastResponseRecieved = line; // signal that we recieved a response and it's ok to move on to the next command mgr.areLineRecieved.Set(); } catch (Exception exc) { System.Diagnostics.Debug.WriteLine(exc.ToString()); System.Diagnostics.Debugger.Break(); } }
private void Driver_LineRecievedEvent(BtSerialCommMgr drv, string line) { MainPage.ShowText(line); }
private void Driver_OnConnect(BtSerialCommMgr drv) { //System.Diagnostics.Debugger.Break(); Instance.showText("Connected."); }