コード例 #1
0
        public static ChineseVersion FormatECUVersionForChina(string hex)
        {
            ChineseVersion ret = new ChineseVersion();

            StringBuilder temp = new StringBuilder();

            temp.Append("ECU");

            for (int i = 0; i < 6; i += 2)
            {
                string e = hex.Substring(i, 2);
                byte   h = Convert.ToByte(e, 16);
                char   c = Convert.ToChar(h);
                if (Char.IsLetterOrDigit(c))
                {
                    temp.Append(c);
                }
            }
            temp.Append("-");

            int beginOfSoftware = 18;

            for (int i = 6; i < 16; i += 2)
            {
                string e = hex.Substring(i, 2);
                byte   h = Convert.ToByte(e, 16);
                char   c = Convert.ToChar(h);
                if (Char.IsLetterOrDigit(c))
                {
                    temp.Append(c);
                }
                else
                {
                    beginOfSoftware -= 2;
                }
            }

            ret.Hardware = temp.ToString();
            temp.Clear();

            for (int i = beginOfSoftware; i < (beginOfSoftware + 12); i += 2)
            {
                string e = hex.Substring(i, 2);
                byte   h = Convert.ToByte(e, 16);
                char   c = Convert.ToChar(h);
                if (Char.IsLetterOrDigit(c))
                {
                    temp.Append(c);
                }
            }

            ret.Software = temp.ToString();
            return(ret);
        }
コード例 #2
0
ファイル: Mikuni.cs プロジェクト: Tomic-Tech/JM.Core
        public static ChineseVersion FormatECUVersionForChina(string hex)
        {
            ChineseVersion ret = new ChineseVersion();

            StringBuilder temp = new StringBuilder();
            temp.Append("ECU");

            for (int i = 0; i < 6; i += 2)
            {
                string e = hex.Substring(i, 2);
                byte h = Convert.ToByte(e, 16);
                char c = Convert.ToChar(h);
                if (Char.IsLetterOrDigit(c))
                    temp.Append(c);
            }
            temp.Append("-");

            int beginOfSoftware = 18;
            for (int i = 6; i < 16; i += 2)
            {
                string e = hex.Substring(i, 2);
                byte h = Convert.ToByte(e, 16);
                char c = Convert.ToChar(h);
                if (Char.IsLetterOrDigit(c))
                {
                    temp.Append(c);
                }
                else
                {
                    beginOfSoftware -= 2;
                }
            }

            ret.Hardware = temp.ToString();
            temp.Clear();

            for (int i = beginOfSoftware; i < (beginOfSoftware + 12); i += 2)
            {
                string e = hex.Substring(i, 2);
                byte h = Convert.ToByte(e, 16);
                char c = Convert.ToChar(h);
                if (Char.IsLetterOrDigit(c))
                    temp.Append(c);
            }

            ret.Software = temp.ToString();
            return ret;
        }