Example #1
0
        private static bool Read_BL_Flash(ushort p_start_addr, int p_byte_count, ref byte[] p_data)
        {
            bool result = true;
            bool flag   = false;
            int  num    = 0;

            byte[] array = new byte[58];
            ushort num2  = p_start_addr;
            int    num3  = p_byte_count / 58;

            if (p_byte_count % 58 != 0)
            {
                flag = true;
                num3++;
            }
            for (int i = 0; i < num3; i++)
            {
                Thread.Sleep(Firmware.m_bootloader_delay);
                byte b;
                if (i == num3 - 1 && flag)
                {
                    b = (byte)(p_byte_count % 58);
                }
                else
                {
                    b = 58;
                }
                if (!Bootloader.Read_One_BL_Flash_USB_Packet(num2, b, ref array))
                {
                    result = false;
                    break;
                }
                for (int j = 0; j < (int)b; j++)
                {
                    p_data[num++] = array[j];
                }
                num2 += (ushort)b;
            }
            return(result);
        }
Example #2
0
        public static bool Read_BL_Flash(ushort p_start_addr, int p_byte_count, ref byte[] p_data)
        {
            bool result = true;
            bool flag   = false;
            int  num    = 0;

            byte[] array = new byte[32];
            ushort num2  = p_start_addr;
            int    num3  = p_byte_count / 32;

            if (p_byte_count % 32 != 0)
            {
                flag = true;
                num3++;
            }
            for (int i = 0; i < num3; i++)
            {
                byte b;
                if (i == num3 - 1 && flag)
                {
                    b = (byte)(p_byte_count % 32);
                }
                else
                {
                    b = 32;
                }
                if (!Bootloader.Read_One_BL_Flash_USB_Packet(num2, b, ref array))
                {
                    result = false;
                    break;
                }
                Thread.Sleep(15);
                for (int j = 0; j < (int)b; j++)
                {
                    p_data[num++] = array[j];
                }
                num2 += (ushort)b;
            }
            return(result);
        }
Example #3
0
        private static bool Read_BL_Flash(ushort p_start_addr, int p_byte_count, ref byte[] p_data)
        {
            bool flag2 = false;
            int  num   = 0;

            byte[] buffer = new byte[0x3a];
            ushort num2   = p_start_addr;
            int    num3   = p_byte_count / 0x3a;
            byte   num4   = 0;

            if ((p_byte_count % 0x3a) != 0)
            {
                flag2 = true;
                num3++;
            }
            for (int i = 0; i < num3; i++)
            {
                Thread.Sleep(m_bootloader_delay);
                if ((i == (num3 - 1)) && flag2)
                {
                    num4 = (byte)(p_byte_count % 0x3a);
                }
                else
                {
                    num4 = 0x3a;
                }
                if (!Bootloader.Read_One_BL_Flash_USB_Packet(num2, num4, ref buffer))
                {
                    return(false);
                }
                for (int j = 0; j < num4; j++)
                {
                    p_data[num++] = buffer[j];
                }
                num2 = (ushort)(num2 + num4);
            }
            return(true);
        }