Esempio n. 1
0
        private static bool parse_hex_file_put_in_array(string p_file_name)
        {
            string str  = "";
            string str2 = "0x";
            string str3 = "0x";
            string str4 = "0x";
            string str5 = "0x";
            int    num  = 0;
            int    num2 = 0;
            bool   flag = true;
            byte   num3 = 0;
            int    num4 = 0;

            if (File.Exists(p_file_name))
            {
                " ,\t".ToCharArray();
                try
                {
                    StreamReader reader = File.OpenText(p_file_name);
                    for (int i = 0; i < m_config_bool_array.Length; i++)
                    {
                        m_config_bool_array[i] = false;
                    }
                    while (reader.Peek() >= 0)
                    {
                        str = reader.ReadLine();
                        if ((str != "") && (str[0] == ':'))
                        {
                            str2 = "0x";
                            str3 = "0x";
                            str4 = "0x";
                            str5 = "0x";
                            num2 = Utilities.Convert_Value_To_Int(str2 + str[1] + str[2]);
                            str4 = (str4 + str[3] + str[4]) + str[5] + str[6];
                            str5 = str5 + str[7] + str[8];
                            num  = Utilities.Convert_Value_To_Int(str4);
                            num3 = (byte)Utilities.Convert_Value_To_Int(str5);
                            if (num3 == 4)
                            {
                                num4++;
                            }
                            if (((num >= 0x2000) && (num < m_upper_fw_addr)) && (num3 == 0))
                            {
                                for (int j = 0; j < (2 * num2); j += 2)
                                {
                                    str3 = "0x";
                                    str3 = str3 + str[9 + j] + str[10 + j];
                                    m_flash_data_array[(num + (j / 2)) - 0x2000] = (byte)Utilities.Convert_Value_To_Int(str3);
                                }
                            }
                            else if (((num4 >= 2) && (num2 > 0)) && (num3 == 0))
                            {
                                for (int k = 0; k < (2 * num2); k += 2)
                                {
                                    str3 = "0x";
                                    str3 = str3 + str[9 + k] + str[10 + k];
                                    m_config_bytes_array[num + (k / 2)] = (byte)Utilities.Convert_Value_To_Int(str3);
                                    m_config_bool_array[num + (k / 2)]  = true;
                                }
                            }
                        }
                    }
                    reader.Close();
                }
                catch (Exception)
                {
                    flag = false;
                }
                return(flag);
            }
            return(false);
        }
Esempio n. 2
0
        public static bool Count_Num_Blocks(string p_file_name, ref int p_num_blocks, ref int p_err_code)
        {
            uint num    = 0u;
            uint num2   = 0u;
            uint num3   = 0u;
            bool flag   = true;
            bool result = true;

            p_err_code = 0;
            if (File.Exists(p_file_name))
            {
                string text = " ,\t";
                text.ToCharArray();
                try
                {
                    StreamReader streamReader = File.OpenText(p_file_name);
                    p_num_blocks = 0;
                    while (streamReader.Peek() >= 0)
                    {
                        string text2 = streamReader.ReadLine();
                        if (text2 == ":00000001FF")
                        {
                            break;
                        }
                        if (text2 != "" && text2[0] == ':')
                        {
                            string text3 = "0x";
                            string text4 = "0x";
                            string text5 = "0x";
                            string text6 = "0x";
                            text3 += text2[1];
                            text3 += text2[2];
                            int num4 = Utilities.Convert_Value_To_Int(text3);
                            text4 += text2[3];
                            text4 += text2[4];
                            text4 += text2[5];
                            text4 += text2[6];
                            text5 += text2[7];
                            text5 += text2[8];
                            uint num5 = (uint)Utilities.Convert_Value_To_Int(text4);
                            byte b    = (byte)Utilities.Convert_Value_To_Int(text5);
                            if (b == 4)
                            {
                                text6 += text2[9];
                                text6 += text2[10];
                                text6 += text2[11];
                                text6 += text2[12];
                                num3   = (uint)Utilities.Convert_Value_To_Int(text6);
                                num3 <<= 16;
                            }
                            else
                            {
                                num5 += num3;
                                if ((num5 / 2u > num2 || num5 / 2u < num) && !flag)
                                {
                                    flag = true;
                                }
                                if (flag)
                                {
                                    p_num_blocks++;
                                    flag = false;
                                    if (!BL16.Calculate_Device_Starting_Block_Addr(num5, ref num, ref num2))
                                    {
                                        streamReader.Close();
                                        p_err_code = 1;
                                        bool result2 = false;
                                        return(result2);
                                    }
                                }
                                for (int i = 0; i < 2 * num4; i += 2)
                                {
                                    string text7 = "0x";
                                    text7 += text2[9 + i];
                                    text7 += text2[10 + i];
                                    if (num > num5 / 2u)
                                    {
                                        streamReader.Close();
                                        p_err_code = 1;
                                        bool result2 = false;
                                        return(result2);
                                    }
                                }
                            }
                        }
                    }
                    streamReader.Close();
                    return(result);
                }
                catch (Exception)
                {
                    p_err_code = 2;
                    result     = false;
                    return(result);
                }
            }
            result     = false;
            p_err_code = 2;
            return(result);
        }
Esempio n. 3
0
        private static bool parse_hex_file_put_in_array(string p_file_name)
        {
            bool result = true;
            int  num    = 0;

            if (File.Exists(p_file_name))
            {
                string text = " ,\t";
                text.ToCharArray();
                try
                {
                    StreamReader streamReader = File.OpenText(p_file_name);
                    for (int i = 0; i < Firmware.m_config_bool_array.Length; i++)
                    {
                        Firmware.m_config_bool_array[i] = false;
                    }
                    while (streamReader.Peek() >= 0)
                    {
                        string text2 = streamReader.ReadLine();
                        if (text2 != "" && text2[0] == ':')
                        {
                            string text3 = "0x";
                            string text4 = "0x";
                            string text5 = "0x";
                            text3 += text2[1];
                            text3 += text2[2];
                            int num2 = Utilities.Convert_Value_To_Int(text3);
                            text4 += text2[3];
                            text4 += text2[4];
                            text4 += text2[5];
                            text4 += text2[6];
                            text5 += text2[7];
                            text5 += text2[8];
                            int  num3 = Utilities.Convert_Value_To_Int(text4);
                            byte b    = (byte)Utilities.Convert_Value_To_Int(text5);
                            if (b == 4)
                            {
                                num++;
                            }
                            if (num3 >= 8192 && num3 < Firmware.m_upper_fw_addr && b == 0)
                            {
                                for (int j = 0; j < 2 * num2; j += 2)
                                {
                                    string text6 = "0x";
                                    text6 += text2[9 + j];
                                    text6 += text2[10 + j];
                                    Firmware.m_flash_data_array[num3 + j / 2 - 8192] = (byte)Utilities.Convert_Value_To_Int(text6);
                                }
                            }
                            else if (num >= 2 && num2 > 0 && b == 0)
                            {
                                for (int k = 0; k < 2 * num2; k += 2)
                                {
                                    string text6 = "0x";
                                    text6 += text2[9 + k];
                                    text6 += text2[10 + k];
                                    Firmware.m_config_bytes_array[num3 + k / 2] = (byte)Utilities.Convert_Value_To_Int(text6);
                                    Firmware.m_config_bool_array[num3 + k / 2]  = true;
                                }
                            }
                        }
                    }
                    streamReader.Close();
                    return(result);
                }
                catch (Exception)
                {
                    result = false;
                    return(result);
                }
            }
            result = false;
            return(result);
        }
Esempio n. 4
0
        public static bool Count_Num_Blocks(string p_file_name, ref int p_num_blocks, ref int p_err_code)
        {
            uint   num   = 0;
            uint   num2  = 0;
            uint   num3  = 0;
            uint   num4  = 0;
            bool   flag  = true;
            string str   = "";
            string str2  = "0x";
            string str3  = "0x";
            string str4  = "0x";
            string str5  = "0x";
            string str6  = "0x";
            int    num5  = 0;
            bool   flag2 = true;
            byte   num6  = 0;

            p_err_code = 0;
            if (File.Exists(p_file_name))
            {
                " ,\t".ToCharArray();
                try
                {
                    StreamReader reader = File.OpenText(p_file_name);
                    p_num_blocks = 0;
                    while (reader.Peek() >= 0)
                    {
                        str = reader.ReadLine();
                        if (str == ":00000001FF")
                        {
                            break;
                        }
                        if ((str != "") && (str[0] == ':'))
                        {
                            str2 = "0x";
                            str3 = "0x";
                            str4 = "0x";
                            str5 = "0x";
                            str6 = "0x";
                            num5 = Utilities.Convert_Value_To_Int(str2 + str[1] + str[2]);
                            str3 = (str3 + str[3] + str[4]) + str[5] + str[6];
                            str4 = str4 + str[7] + str[8];
                            num  = (uint)Utilities.Convert_Value_To_Int(str3);
                            num6 = (byte)Utilities.Convert_Value_To_Int(str4);
                            if (num6 == 4)
                            {
                                num4 = (uint)(Utilities.Convert_Value_To_Int((str5 + ((char)str[9]) + ((char)str[10])) + ((char)str[11]) + ((char)str[12])) << 0x10);
                            }
                            else
                            {
                                num += num4;
                                if ((((num / 2) > num3) || ((num / 2) < num2)) && !flag)
                                {
                                    flag = true;
                                }
                                if (flag)
                                {
                                    p_num_blocks++;
                                    flag = false;
                                    if (!Calculate_Device_Starting_Block_Addr(num, ref num2, ref num3))
                                    {
                                        reader.Close();
                                        p_err_code = 1;
                                        return(false);
                                    }
                                }
                                for (int i = 0; i < (2 * num5); i += 2)
                                {
                                    str6 = "0x";
                                    str6 = str6 + str[9 + i] + str[10 + i];
                                    if (num2 > (num / 2))
                                    {
                                        reader.Close();
                                        p_err_code = 1;
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                    reader.Close();
                }
                catch (Exception)
                {
                    p_err_code = 2;
                    flag2      = false;
                }
                return(flag2);
            }
            flag2      = false;
            p_err_code = 2;
            return(flag2);
        }