Ejemplo n.º 1
0
        //2DO
        public String ReadFlashPage(UInt16 pageNum)
        {
            string str = "";

            Send('f');
            ClearBuffer();
            //Adress
            byte[] ba = BitConverter.GetBytes((pageNum + 1) * 0xFF);
            Send(ba[0]);
            Send(ba[1]);

            for (int j = 0; j < device.FlashPageSize; j++)
            {
                byte b = 0x00;
                TimeOut.DoWork(delegate { b = ReadByte(); }, 501);
                str += String.Format("{0:X2}", b);
            }
            return(str);
        }
Ejemplo n.º 2
0
        public String ReadFlash(string filename)
        {
            FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write);

            string str = "";

            Console.WriteLine("  0%                          100%");
            Console.WriteLine("  V                            V");
            Console.Write("  ");
            int lastnum = 0;

            for (int i = 0; i < device.FlashPages; i++)
            {
                Send('f');
                ClearBuffer();
                //Adress
                byte[] ba = BitConverter.GetBytes((i + 1) * 0xFF);
                Send(ba[0]);
                Send(ba[1]);

                for (int j = 0; j < device.FlashPageSize; j++)
                {
                    byte b = 0x00;
                    TimeOut.DoWork(delegate { b = ReadByte(); }, 501);
                    fs.WriteByte(b);
                    str += String.Format("{0:X2}", b);
                }
                //Console.WriteLine(str);
                int newnum = (int)((float)30 * i / (device.FlashPages - 1));
                for (int k = 0; k < (newnum - lastnum); k++)
                {
                    Console.Write("|");
                }
                lastnum = newnum;
                str     = "";
            }
            Console.WriteLine();
            fs.Flush();
            fs.Close();
            return(str);
        }