Exemple #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     button1_Click(null, null);
     button2_Click(null, null);
     Usart1         = new Usart(serialPort1);
     DevAddr        = byte.Parse(comboBox3.Text);
     comboBox3.Text = Ini.Read("DEVID");
     Read_UpDataInfor();
 }
Exemple #2
0
 private string Read_UpDataInfor()
 {
     try
     {
         string name = Ini.Read("附件路径");
         richTextBox1.Text = "文件路径:" + name + "\r\n";
         FileInfo FI = new FileInfo(name);
         richTextBox1.AppendText("文件大小:" + FI.Length.ToString() + " Bytes");
         return(name);
     }
     catch { }
     return("NULL");
 }
Exemple #3
0
        private void button12_Click(object sender, EventArgs e)
        {
            byte[]   Buf  = new byte[1500];
            byte[]   Tata = new byte[8];
            FileInfo fi   = new FileInfo(Ini.Read("附件路径"));
            uint     len  = (uint)fi.Length;

            Tools.ByteFromU32(len, ref Tata, 0, 0);
            Tata[4] = 0x19;
            Tata[5] = 0x89;
            Tata[6] = 0x11;
            Tata[7] = 0x06;
            int Length = ZigBeeBus.ZigBee_SendMsg(ref Buf, DevAddr, (byte)ACFF.SCFF_EraseFlase, Tata, (byte)Tata.Length);

            ZigBeeBus.ZigBee_CheckCrc(Buf);
            Usart1.WriteBuffer(Buf, Length);
        }
Exemple #4
0
        private void DownLoad_Thread()
        {
            for (int z = 0; z < 10; z++)
            {
                RxCount = 0;
                button12_Click(null, null);
                for (int a = 0; a < 10; a++)
                {
                    Thread.Sleep(100);
                    if (RxCount > 5)
                    {
                        z += 1;
                    }
                }
                if (RxCount < 5)
                {
                    z--;
                }
            }
            FileInfo   fi  = new FileInfo(Ini.Read("附件路径"));
            uint       len = (uint)fi.Length;
            FileStream fs  = new FileStream(Ini.Read("附件路径"), FileMode.Open);

            byte[] buffer = new byte[len];
            fs.Read(buffer, 0, (int)len); fs.Close();
            fs.Close();
            uint PageSize = len / 1024;

            if ((len % 1024) > 0)
            {
                PageSize++;
            }
            for (int z = 0; z < PageSize; z++)
            {
                this.Invoke((EventHandler)(delegate
                {
                    this.progressBar1.Maximum = (int)(PageSize - 1);
                    this.progressBar1.Value = z;
                    Application.DoEvents();
                }));
                byte[] Data = new byte[1024];
                for (int i = 0; i < 1024; i++)
                {
                    try { Data[i] = buffer[1024 * z + i]; } catch { Data[i] = 0xff; }
                }
                RxCount = 0;
                WritePage(Data, z);
                for (int a = 0; a < 10; a++)
                {
                    if (RxCount > 5)
                    {
                        break;
                    }
                    Thread.Sleep(10);
                }
                if (RxCount < 5)
                {
                    z--;
                }
            }
            button3_Click(null, null);
            button3_Click(null, null);
            this.Invoke((EventHandler)(delegate
            {
                this.progressBar1.Value = 0;
                button9.Text = "写入文件";
                Application.DoEvents();
            }));
        }