Ejemplo n.º 1
0
 /// <summary>
 /// 分析QSW响应包
 /// </summary>
 private static void AnalyzeQSW_resp(QSW_Recv qsw, int packagesNum)
 {
     Console.WriteLine("QSW Response in last package:");
     if (qsw.updataStatus[0] != 5)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("Status: " + qsw.updataStatus[0].ToString("X2") + " " +
                           QSWMessage.UpdateStatusMsg((UpdateStatus)qsw.updataStatus[0]));
         Console.ResetColor();
     }
     else
     {
         Console.WriteLine("Status: " + qsw.updataStatus[0].ToString("X2") + " " +
                           QSWMessage.UpdateStatusMsg((UpdateStatus)qsw.updataStatus[0]));
     }
     if (qsw.updataResult[0] != 0)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("Result: " + qsw.updataResult[0].ToString("X2") + " " +
                           QSWMessage.UpdateResultMsg((UpdateResult)qsw.updataResult[0]));
         Console.ResetColor();
     }
     else
     {
         Console.WriteLine("Result: " + qsw.updataResult[0].ToString("X2") + " " +
                           QSWMessage.UpdateResultMsg((UpdateResult)qsw.updataResult[0]));
     }
     Console.ForegroundColor = ConsoleColor.Red;
     Console.WriteLine(QSWMessage.CheckPackagesFlag(qsw.packageFlag, packagesNum));
     Console.ResetColor();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 从串口文件中取到所有的有效升级数据包和响应包
        /// </summary>
        /// <param name="file">文件路径和文件名</param>
        /// <param name="fileType">文件类型 0 为bin文件 1 为文本文件</param>
        private void GetPackageList(string file, int fileType)
        {
            byte[] fff;
            if (fileType == 0)
            {
                FileUtility.GetDataFromBinFile(file, out fff);
            }
            else if (fileType == 1)
            {
                FileUtility.GetDataFormTxtFile(file, out fff);
            }
            else
            {
                return;
            }

            for (int i = 0; i < fff.Length; i++)
            {
                if (fff[i] == 'S' && fff[i + 1] == 'S' && fff[i + 2] == 'W')
                {
                    var ssws = new SSW_Send(ByteUtility.GetSubByte(fff, i, 25));
                    if (ssws.isValid)
                    {
                        this.sswSendList.Add(ssws);
                    }
                    else
                    {
                        var sswr = new SSW_Recv(ByteUtility.GetSubByte(fff, i, 9));
                        if (sswr.isValid)
                        {
                            this.sswRecvList.Add(sswr);
                        }
                    }
                }
                else if (fff[i] == 'U' && fff[i + 1] == 'S' && fff[i + 2] == 'W')
                {
                    var usws = new USW_Send(ByteUtility.GetSubByte(fff, i, 523));
                    if (usws.isValid)
                    {
                        this.uswSendList.Add(usws);
                    }
                    else
                    {
                        var uswr = new USW_Recv(ByteUtility.GetSubByte(fff, i, 10));
                        if (uswr.isValid)
                        {
                            this.uswRecvList.Add(uswr);
                        }
                    }
                }
                else if (fff[i] == 'Q' && fff[i + 1] == 'S' && fff[i + 2] == 'W')
                {
                    var qsws = new QSW_Send(ByteUtility.GetSubByte(fff, i, 8));
                    if (qsws.isValid)
                    {
                        this.qswSendList.Add(qsws);
                    }
                    else
                    {
                        var qswr = new QSW_Recv(ByteUtility.GetSubByte(fff, i, 32));
                        if (qswr.isValid)
                        {
                            this.qswRecvList.Add(qswr);
                        }
                    }
                }
            }
        }