Ejemplo n.º 1
0
        public void Setup_BootLoader()
        {
            Viewer.UpadateLogInvoke UpdateLog = LogUpdate;
            int count = 0;

            byte[]         Filedata = new byte[1024];
            ivt_BootLoader BL       = new ivt_BootLoader();

            Sdp_Handler.WriteCommand(4, 539001344, Convert.ToInt32(BL.BootLoader.Length));
            while (count < BL.BootLoader.Length)
            {
                if (count + Filedata.Length > BL.BootLoader.Length)
                {
                    byte[] partdata = new byte[BL.BootLoader.Length - count];
                    Array.Copy(BL.BootLoader, count, partdata, 0, partdata.Length);
                    Sdp_Handler.WriteData(partdata);
                    count += partdata.Length;
                }
                else
                {
                    Array.Copy(BL.BootLoader, count, Filedata, 0, Filedata.Length);
                    Sdp_Handler.WriteData(Filedata);
                    count += Filedata.Length;
                }
            }

            Sdp_Handler.WriteCommand(11, 539001344, 0);
            System.Threading.Thread.Sleep(1000);
            Invoke(UpdateLog, new Object[] { "Recovery Success, Reinitializing FW Upgrade Menager...", true });
        }
Ejemplo n.º 2
0
 private void btn_SDP_Connect_Click(object sender, EventArgs e)
 {
     Sdp_Handler = SDP_Handler.Enumerate(0x1FC9, new[] { 0x0130 }).FirstOrDefault();
     if (Sdp_Handler != null)
     {
         Sdp_Handler.DataRecieved += PushReceiveData;
         Sdp_Handler.Inserted     += DeviceInserted;
         Sdp_Handler.Removed      += DeviceRemoved;
         Sdp_Handler.StartListen();
     }
 }
Ejemplo n.º 3
0
        private void btn_onekeyupdate_Click(object sender, EventArgs e)
        {
            btn_onekeyupdate.Enabled = false;
            bool BL_connect = false;

            Viewer.UpdateProgressBarCallback UpdateProgressBar = Assign_ProgressBar;
            Viewer.UpadateLogInvoke          UpdateLog         = LogUpdate;

            if (Viewer.fingerPrint == null)
            {
                Viewer.fingerPrint = new FingerPrint_API.FingerPrint();
                Viewer.fingerPrint.AutoConnect_Interval = 5000;
            }
            if (!Viewer.fingerPrint.IsConnected)
            {
                InitialDvice(true);
            }
            bool force_try = false;

            if (!Viewer._Initial)
            {
                DialogResult dr = MessageBox.Show("Can't Find Appropriate Device, Try Recovery?", "Connect Failed", MessageBoxButtons.YesNo);

                force_try = (dr == DialogResult.Yes) ? true : false;
            }

            if (Viewer._Initial || force_try)
            {
                int BLtry_count = 0;
                Invoke(UpdateLog, new Object[] { "Initializing FW Update Menager...", true });
                Invoke(UpdateLog, new Object[] { "Please Waiting...", false });
                while (Bl_Handler == null && BLtry_count < 5)
                {
                    Invoke(UpdateLog, new Object[] { "...", false });
                    System.Threading.Thread.Sleep(1000);
                    Bl_Handler = BL_Handler.Enumerate(0x15A2, new[] { 0x0073 }).FirstOrDefault();
                    BLtry_count++;
                }
                Invoke(UpdateLog, new Object[] { " ", true });
                if (Bl_Handler != null)
                {
                    Bl_Handler.LogUpdate    += UpdateLogFromHandler;
                    Bl_Handler.DataRecieved += ReceiveDataFlag;
                    Bl_Handler.StartListen();
                    BL_connect = true;
                    Invoke(UpdateLog, new Object[] { "Initializing FW Update Menager Success...", true });
                }
                else
                {
                    Invoke(UpdateLog, new Object[] { "Initializing Failed, Recovery Function Start...", true });

                    Sdp_Handler = SDP_Handler.Enumerate(0x1FC9, new[] { 0x0130 }).FirstOrDefault();
                    if (Sdp_Handler != null)
                    {
                        Sdp_Handler.DataRecieved += ReceiveDataFlag;
                        Sdp_Handler.StartListen();

                        Setup_BootLoader();
                    }
                    else
                    {
                        Invoke(UpdateLog, new Object[] { "Recovery Failed, Terminated...", true });
                    }
                }

                System.Threading.Thread.Sleep(3000);
                // Reconnect
                if (!BL_connect)
                {
                    Bl_Handler = BL_Handler.Enumerate(0x15A2, new[] { 0x0073 }).FirstOrDefault();
                    if (Bl_Handler != null)
                    {
                        Bl_Handler.LogUpdate    += UpdateLogFromHandler;
                        Bl_Handler.DataRecieved += ReceiveDataFlag;
                        Bl_Handler.StartListen();
                        BL_connect = true;
                        Invoke(UpdateLog, new Object[] { "Initializing FW Update Menager Success...", true });
                    }
                    else
                    {
                        Invoke(UpdateLog, new Object[] { "Initializing FW Upgrade Menager Fail... Terminated", true });
                    }
                }

                if (BL_connect)
                {
                    string ImageFilePath = tb_allinone_path.Text;
                    //Check Recipe//
                    if (!File.Exists("Auto_Recipe.txt"))
                    {
                        Invoke(UpdateLog, new Object[] { "Recipe Loss, Please Contact For Support", true });
                    }
                    else
                    {
                        Check_Recipe();
                        byte[] Image_data = Load_Image(ImageFilePath);
                        if (File_Support)
                        {
                            Do_Command(Image_data);
                        }
                        Invoke(UpdateLog, new Object[] { "Process Done", true });
                    }
                }
                if (File_Support)
                {
                    Viewer._Initial = false;
                    int try_count = 0;
                    Viewer.fingerPrint.Dispose();
                    Viewer.fingerPrint = new FingerPrint_API.FingerPrint();
                    rt_log.Text       += "Verificating...\n";
                    while (!Viewer._Initial && try_count < 3)
                    {
                        try_count++;
                        System.Threading.Thread.Sleep(3000);
                        InitialDvice(false);
                    }
                    if (!Viewer._Initial)
                    {
                        Invoke(UpdateLog, new Object[] { "Updated Failed Please Check Your Image File And Restart Upgrade Program", true });
                    }
                }
            }
            btn_onekeyupdate.Enabled = true;
        }
Ejemplo n.º 4
0
        private void btn_sent_SDP_Click(object sender, EventArgs e)
        {
            btn_sent_SDP.Enabled = false;
            Viewer.UpadateDataMapInvoke      UpdateDataMap     = Data_Process;
            Viewer.UpadateLogInvoke          UpdateLog         = LogUpdate;
            Viewer.UpdateProgressBarCallback UpdateProgressBar = Assign_ProgressBar;
            Invoke(UpdateProgressBar, 0);
            int addr_int = Int32.Parse(tb_addr.Text, System.Globalization.NumberStyles.HexNumber);

            int datacount = Convert.ToInt32(tb_datacount.Text);

            byte[] data = new byte[datacount];
            int    row = 0, col = 0, pcount = 0;

            if (cb_command_type.Text == "WRITE_REGISTER" || cb_command_type.Text == "WRITE_FILE")
            {
                while (pcount < datacount && dgv_datamap.Rows[row].Cells[col].Value != null)
                {
                    data[pcount] = byte.Parse(dgv_datamap.Rows[row].Cells[col].Value.ToString(), System.Globalization.NumberStyles.HexNumber);
                    pcount++;
                    col = (col + 1 > dgv_datamap.ColumnCount - 1) ? 0 : col++;
                    if (col == 0)
                    {
                        row = (row + 1 > dgv_datamap.RowCount) ? row : row++;
                    }
                }
            }

            Invoke(UpdateDataMap, new string[] { null });
            int command_type = 0;

            switch (cb_command_type.Text)
            {
            case "READ_REGISTER":
                command_type = 1;
                Sdp_Handler.WriteCommand(command_type, addr_int, datacount);
                break;

            case "WRITE_REGISTER":
                command_type = 2;
                Sdp_Handler.WriteCommand(command_type, addr_int, datacount, data);
                break;

            case "WRITE_FILE":
                command_type = 4;
                int        count       = 0;
                long       preposition = 0;
                byte[]     Filedata    = new byte[1024];
                FileStream fileStream  = new FileStream(tb_filepath.Text, FileMode.Open, FileAccess.Read);
                Invoke(UpdateLog, "File Length : " + fileStream.Length, true);
                Invoke(UpdateProgressBar, 20);
                Invoke(UpdateLog, "Start", true);
                Sdp_Handler.WriteCommand(command_type, addr_int, Convert.ToInt32(fileStream.Length));
                while (fileStream.Read(Filedata, 0, Filedata.Length) > 0)
                {
                    if (fileStream.Position == fileStream.Length)
                    {
                        byte[] partdata = new byte[fileStream.Position - preposition];
                        Array.Copy(Filedata, partdata, partdata.Length);
                        Sdp_Handler.WriteData(partdata);
                        count += partdata.Length;
                    }
                    else
                    {
                        Sdp_Handler.WriteData(Filedata);
                        count += Filedata.Length;
                    }
                    Debug.WriteLine("Write Count : " + count);
                    preposition = fileStream.Position;
                }
                break;

            case "ERROR_STATUS":
                command_type = 5;
                Sdp_Handler.WriteCommand(command_type, 0, 0);
                break;

            case "DCD_WRITE":
                command_type = 10;
                break;

            case "JUMP_ADDRESS":
                command_type = 11;
                Sdp_Handler.WriteCommand(command_type, addr_int, 0);
                break;

            default:
                MessageBox.Show("Please Select Command Type");
                break;
            }

            Invoke(UpdateLog, "Command Process Done", true);
            btn_sent_SDP.Enabled = true;
            Invoke(UpdateProgressBar, 100);
        }