/// <summary> /// 关闭GPS时钟串口 /// </summary> /// <returns></returns> public bool CloseGpsCom() { GpsCom.Close(); IsClockOpened = GpsCom.IsOpen; if (GpsCom.IsOpen) { return(false); } else { return(true); } }
/// <summary> /// 打开GPS时钟串口 /// </summary> /// <returns></returns> public bool OpenGpsClockCom() { try { GpsCom.Open(); } catch { } IsClockOpened = GpsCom.IsOpen; if (GpsCom.IsOpen) { return(true); } else { return(false); } }
/// <summary> /// GPS时钟接收处理程序B /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GpsClock_DataReceivedB(object sender, SerialDataReceivedEventArgs e) { try { StringBuilder currentline = new StringBuilder(); //循环接收数据 while (GpsCom.BytesToRead > 0) { char ch = (char)GpsCom.ReadByte(); currentline.Append(ch); } //在这里对接收到的数据进行处理 // currentline = new StringBuilder(); } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } }