public void Start(byte SID, byte TID, bool selectDefaultState, int selIntMs, int toutIntMs) { if (!isWaiting) { var msg = NMEAParser.BuildProprietarySentence(ManufacturerCodes.MCP, "1", new object[] { SID, TID, Convert.ToInt32(selectDefaultState), selIntMs, toutIntMs }); port.SendData(msg); isWaiting = true; } }
private void SafelySend(string msg) { try { port.SendData(msg); timer.Start(); } catch (Exception ex) { RestartPort(); } }
private bool RequestDevInfo() { InvokeWriteStateLbl("Querying"); InvokeWriteLogString("Querying device info...\r\n"); InvokeSwitchProgressBarMode(ProgressBarStyle.Marquee); bool result = false; var cmdStr = NMEAParser.BuildProprietarySentence(ManufacturerCodes.UCN, "L", new object[] { (int)UCNL_SRV_CMD.DEV_INFO_GET, 0, "" }); try { nmeaPort.SendData(cmdStr); result = true; timer.Start(); InvokeWriteLogString(string.Format(">> {0}", cmdStr)); } catch (Exception ex) { ProcessException(ex, false); } return(result); }
private bool TrySend(string message) { bool result = false; try { port.SendData(message); result = true; } catch (Exception ex) { } return(result); }
private void Send(string msg) { try { port.SendData(msg); if (!isServiceTab) { bytesSent += msg.Length; } InvokeAppendText(commLogTxb, logger.Write(string.Format("<< {0}", msg))); } catch (Exception ex) { InvokeAppendText(commLogTxb, logger.Write(ex)); MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void gtr_TrySend(string msg, string queryDescription, bool isRemote) { try { gtrPort.SendData(msg); logger.Write(string.Format("{0} (RedGTR) << {1}", gtrPort.PortName, msg)); gtr_lastQuery = queryDescription; gtr_isWaiting = true; gtr_timeoutCounter = 0; if (isRemote) { gtr_isWaitingRemote = true; gtr_remoteTimeoutCounter = 0; } } catch (Exception ex) { ProcessException(ex, false); } }
private bool TrySend(string message, ICs queryID) { bool result = IsCommandMode && port.IsOpen && !IsWaitingLocal; if (result) { try { port.SendData(message); IsWaitingLocal = true; lastQueryID = queryID; result = true; OnInfoEvent(string.Format("<< {0}", message)); } catch (Exception ex) { OnInfoEvent(ex); } } return(result); }
private bool CheckNextPort() { portSettings.PortName = portNames[curPortIdx]; bool result = false; try { port = new NMEASerialPort(portSettings); port.NewNMEAMessage = new EventHandler <NewNMEAMessageEventArgs>(port_NewNMEAMessage); port.PortError = new EventHandler <SerialErrorReceivedEventArgs>(port_PortError); port.Open(); var queryStr = NMEAParser.BuildProprietarySentence(ManufacturerCodes.TNT, "4", new object[] { (int)LocalDataIDs.LOC_DATA_DEVICE_INFO, 0 }); port.SendData(queryStr); if (ConnectionEstablished != null) { ConnectionEstablished(this, new EventArgs()); } timer.Start(); result = true; } catch (Exception ex) { if (port.IsOpen) { port.Close(); } UnsubscribePort(); port.Dispose(); } return(result); }
private void SendEMU(double tLat, double tLon, double tdpt, double tRErr) { // "hhmmss.ss,A=Valid|V=Invalid,llll.ll,N=North|S=South,yyyyy.yy,E=East|W=West,x.x,x.x,ddmmyy,x.x,a,a" }, // $GPRMC,105552.000,A,4831.4568,N,04430.2342,E,0.17,180.99,230518,,,A*6F string latCardinal; if (tLat > 0) { latCardinal = "North"; } else { latCardinal = "South"; } string lonCardinal; if (tLon > 0) { lonCardinal = "East"; } else { lonCardinal = "West"; } StringBuilder sb = new StringBuilder(); sb.Append(NMEAParser.BuildSentence(TalkerIdentifiers.GN, SentenceIdentifiers.RMC, new object[] { DateTime.Now, "Valid", tLat, latCardinal, tLon, lonCardinal, null, // speed knots null, // track true DateTime.Now, null, // magnetic variation null, // magnetic variation direction "A", })); // "hhmmss.ss,llll.ll,a,yyyyy.yy,a,0=Fix not availible|1=GPS fix|2=DGPS fix,xx,x.x,x.x,M,x.x,M,x.x,xxxx" }, sb.Append(NMEAParser.BuildSentence(TalkerIdentifiers.GN, SentenceIdentifiers.GGA, new object[] { DateTime.Now, tLat, latCardinal[0], tLon, lonCardinal[0], "GPS fix", settingsProvider.Data.BaseSize, tRErr, -tdpt, "M", null, "M", null, null })); try { gnssEmulatorPort.SendData(sb.ToString()); } catch (Exception ex) { ProcessException(ex, false); } }