Пример #1
0
        void EraseFlash()
        {
            serial_listener.BeginListening();
            string cmd = "PCCEF";

            port.WriteLine("$" + cmd + "*" + SerialPortListener.CalculateCRC(cmd));
        }
Пример #2
0
        void GetDeviceVersion()
        {
            serial_listener.BeginListening();
            string cmd = "PCVER";

            port.WriteLine("$" + cmd + "*" + SerialPortListener.CalculateCRC(cmd));
        }
Пример #3
0
        void GetDeviceIdentifier()
        {
            serial_listener.BeginListening();
            string cmd = "PCHND";

            port.WriteLine("$" + cmd + "*" + SerialPortListener.CalculateCRC(cmd));
        }
Пример #4
0
        private void DeviceConfigForm_Load(object sender, EventArgs e)
        {
            setText            = new SetTextbox(SetText);
            getTimeHandler     = new DeviceDataReceivedEventHandler(listener_GetTimeRecIntervalReceived);
            getDistanceHandler = new DeviceDataReceivedEventHandler(listener_GetDistanceRecIntervalReceived);

            listener = (this.Owner as MainUnit).Listener;
            listener.GetTimeRecIntervalReceived     += getTimeHandler;
            listener.GetDistanceRecIntervalReceived += getDistanceHandler;
            GetTimeRecInterval(this.Owner as MainUnit);
            GetDistanceRecInterval(this.Owner as MainUnit);
        }
Пример #5
0
 private void SetupComPort(string portname)
 {
     SetPortParams(portname);
     serial_listener = new SerialPortListener(port);
     serial_listener.DeviceIdReceived               += new DeviceDataReceivedEventHandler(serial_listener_DeviceIdReceived);
     serial_listener.DeviceVersionReceived          += new DeviceDataReceivedEventHandler(serial_listener_DeviceVersionReceived);
     serial_listener.PageReceived                   += new DeviceDataReceivedEventHandler(serial_listener_PageReceived);
     serial_listener.SetDeviceSerialSpeedOkReceived += new DeviceDataReceivedEventHandler(serial_listener_SetDeviceSerialSpeedOkReceived);
     serial_listener.DeviceErrorReceived            += new DeviceDataReceivedEventHandler(serial_listener_DeviceErrorReceived);
     serial_listener.ErasePageReceived              += new DeviceDataReceivedEventHandler(serial_listener_ErasePageReceived);
     serial_listener.EraseOkReceived                += new DeviceDataReceivedEventHandler(serial_listener_EraseOkReceived);
 }
Пример #6
0
 void SetDeviceSpeed(string speed)
 {
     if (speed == "9600" || speed == "19200" || speed == "38400" || speed == "57600" || speed == "115200" || speed == "230400")
     {
         string cmd = "PCSCS " + speed;
         port.WriteLine("$" + cmd + "*" + SerialPortListener.CalculateCRC(cmd));
     }
     else
     {
         throw new ArgumentOutOfRangeException("speed", "Only 9600, 19200, 38400, 57600, 115200, 230400 values are allowed");
     }
 }
Пример #7
0
        void dummyTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                string message = "GPRMC,095344.000,V,5025.8244,N,03032.6861,E,0.00,243.66,211108,,,A";
                virtualport.DataToPort("$" + message + "*" + SerialPortListener.CalculateCRC(message) + "\r\n");
            }
#pragma warning disable 168
            catch (Exception except)
            {
            }
#pragma warning restore 168
        }
Пример #8
0
 public void SendCommand(string cmd)
 {
     serial_listener.BeginListening();
     port.WriteLine("$" + cmd + "*" + SerialPortListener.CalculateCRC(cmd));
 }
Пример #9
0
        void SetRecTimeInterval(string interval)
        {
            string cmd = "PCSDT " + interval;

            port.WriteLine("$" + cmd + "*" + SerialPortListener.CalculateCRC(cmd));
        }
Пример #10
0
        void SetDefaults()
        {
            string cmd = "PCSFS";

            port.WriteLine("$" + cmd + "*" + SerialPortListener.CalculateCRC(cmd));
        }
Пример #11
0
        void ReadPage(string pagenum)
        {
            string cmd = "PCREP " + pagenum;

            port.WriteLine("$" + cmd + "*" + SerialPortListener.CalculateCRC(cmd));
        }
Пример #12
0
        void workingTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                DataGridView grid = (this.Invoke(getSelectedGrid) as DataGridView);
                if (currentRow >= (grid.Rows.Count - 1))
                {
                    currentRow = 0;
                }
                else
                {
                    //(sender as System.Timers.Timer).Stop();
                    StringBuilder buf;

                    buf = new StringBuilder("GPRMC,");

                    DateTime time = DateTime.Parse((grid.Rows[currentRow].Cells[0].Value as string) + " " + (grid.Rows[currentRow].Cells[1].Value as string));
                    time = DateTime.SpecifyKind(time, DateTimeKind.Local).ToUniversalTime();
                    string timestr = time.ToLongTimeString();
                    if (timestr.Length == 7)
                    {
                        timestr = "0" + timestr;
                    }
                    buf.Append(timestr.Replace(":", ""));
                    buf.Append(".000,A,");

                    buf.Append((grid.Rows[currentRow].Cells[2].Value as string).Replace("°", "").Replace(',', '.'));
                    buf.Append(",N,0");
                    buf.Append((grid.Rows[currentRow].Cells[3].Value as string).Replace("°", "").Replace(',', '.'));
                    buf.Append(",E,27.00,243.66,");
                    //buf.Append((grid.Rows[currentRow].Cells[0].Value as string).Replace(".", ""));
                    buf.Append(time.ToShortDateString().Replace(".", ""));
                    buf.Remove(buf.Length - 4, 2);
                    buf.Append(",,,A");

                    /*buf = buf.Replace(":", "");
                     * buf = buf.Replace(".", "");
                     * buf = buf.Replace(",", "");
                     * buf = buf.Replace("°", "");
                     * buf = buf.Remove(buf.Length - 4, 2);*/

                    virtualport.DataToPort("$" + buf.ToString() + "*" + SerialPortListener.CalculateCRC(buf.ToString()) + "\r\n");
                    string ggaSentence = "GPGGA," + buf.ToString().Substring(7, 11) + buf.ToString().Substring(20, 25) + "1,06,1.4,180.5,M,27.8,M,,0000";
                    virtualport.DataToPort("$" + ggaSentence + "*" + SerialPortListener.CalculateCRC(ggaSentence) + "\r\n");
                    virtualport.DataToPort("$GPGSA,A,3,29,30,31,05,24,02,,,,,,,3.4,1.4,.1*39\r\n");

                    if (currentRow % 5 == 0)
                    {
                        virtualport.DataToPort("$GPGSV,3,1,11,30,80,169,21,29,70,267,46,05,53,140,31,24,45,178,31*7F\r\n");
                        virtualport.DataToPort("$GPGSV,3,2,11,12,40,128,,02,40,059,27,31,37,295,46,10,17,105,*72\r\n");
                        virtualport.DataToPort("$GPGSV,3,3,11,21,09,203,,04,02,039,,23,01,357,*4F\r\n");
                    }

                    currentRow++;
                }
            }
#pragma warning disable 168
            catch (NullReferenceException except)
            {
                this.Invoke(new EventHandler(stopBtn_Click), new object(), new EventArgs());
                MessageBox.Show("Нет данных для отображения", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception except)
            {
            }
#pragma warning restore 168
        }