Пример #1
0
        private void TimerConnectServer_Tick(object sender, EventArgs e)
        {
            Debug.WriteLine("Timer!");

            if (m_MyTcpClientArm != null && !m_MyTcpClientArm.IsConnected)
            {
                m_MyTcpClientArm.Close();

                m_MyTcpClientArm = new MyTcpClient();
                IPAddress ControlIp   = IPAddress.Parse(TextBoxIp.Text);
                int       ControlPort = int.Parse(TextBoxPort.Text);
                m_MyTcpClientArm.CreateConnect(ControlIp, ControlPort);
            }

            if (m_MyTcpClientArm != null && m_MyTcpClientArm.IsConnected)
            {
                TimerConnectServer.Stop();
                m_UpdateAction = UpdateAction.UpdateAction_SendFileLength;
            }
        }
Пример #2
0
        private void BtnUpdate_Click(object sender, EventArgs e)
        {
            this.UpdateOpenFileDialog.FileName = ".bin";
            if (UpdateOpenFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            m_UpdateFileName = UpdateOpenFileDialog.FileName;
            m_InputStream    = File.Open(m_UpdateFileName, FileMode.Open);
            m_Reader         = new BinaryReader(m_InputStream);

            if (m_MyTcpClientArm != null)
            {
                m_MyTcpClientArm.InitClient();

                IPAddress ControlIp   = IPAddress.Parse(TextBoxIp.Text);
                int       ControlPort = int.Parse(TextBoxPort.Text);
                m_MyTcpClientArm.CreateConnect(ControlIp, ControlPort);
            }

            //发送升级指令
            Array.Clear(m_SendCommand, 0, m_SendCommand.Length);
            Message.MakeSendArrayByCode((byte)Message.MessageCodeARM.ArmUpdate, ref m_SendCommand);
            if (m_MyTcpClientArm != null && m_MyTcpClientArm.IsConnected)
            {
                m_MyTcpClientArm.ClientWrite(m_SendCommand);
            }

            //创建升级线程
            m_MainThread = new Thread(new ThreadStart(MainThreadFunc));
            m_MainThread.IsBackground = true;
            m_MainThread.Start();

            UpdateProcessBar.Value = UpdateProcessBar.Minimum;
        }