コード例 #1
0
ファイル: Form1.cs プロジェクト: zhuhaijun753/DiagnosticTool
        private string get_page2()
        {
            string s = Out2.Substring(count, 256);

            count += 256;
            return(s);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: zhuhaijun753/DiagnosticTool
        private void WriteData2()
        {
            int offset = 0, no_of_pages;

            byte[] intBytes;


            no_of_pages = Out2.Length / 256;
            while (no_of_pages > 0)
            {
                writeAddress(64 * offset);
                wait_ARV_response();
                serialPort1.Write(new char[] { 'd' }, 0, 1);
                data_per_page = get_page2();
                intBytes      = BitConverter.GetBytes(data_per_page.Length / 2);
                tempByte      = intBytes[1];
                intBytes[1]   = intBytes[0];
                intBytes[0]   = tempByte;
                //Console.WriteLine(intBytes);
                serialPort1.Write(intBytes, 0, 2);
                serialPort1.Write(new char[] { 'F' }, 0, 1);
                write_page(data_per_page);

                //WriteData();

                serialPort1.Write(new char[] { ' ' }, 0, 1);
                wait_ARV_response();
                offset++;
                no_of_pages--;
            }
            // writting last page

            /*writeAddress(64 * offset);
             *  serialPort1.Write(new char[] { 'd' }, 0, 1);
             *  data_per_page = Out2.Substring(count);
             *  intBytes = BitConverter.GetBytes(data_per_page.Length / 2);
             *  tempByte = intBytes[1];
             *  intBytes[1] = intBytes[0];
             *  intBytes[0] = tempByte;
             *  //Console.WriteLine(intBytes);
             *  serialPort1.Write(intBytes, 0, 2);
             *  serialPort1.Write(new char[] { 'F' }, 0, 1);
             *  write_page(data_per_page);
             *
             *  //WriteData();
             *
             *  serialPort1.Write(new char[] { ' ' }, 0, 1);
             */
            // writting last page ( size may be less than 128)
            writeAddress(64 * offset);
            wait_ARV_response();
            serialPort1.Write(new char[] { 'd' }, 0, 1);
            data_per_page = Out2.Substring(count);
            intBytes      = BitConverter.GetBytes(data_per_page.Length / 2);
            tempByte      = intBytes[1];
            intBytes[1]   = intBytes[0];
            intBytes[0]   = tempByte;
            //Console.WriteLine(intBytes);
            serialPort1.Write(intBytes, 0, 2);
            serialPort1.Write(new char[] { 'F' }, 0, 1);
            write_page(data_per_page);
            serialPort1.Write(new char[] { ' ' }, 0, 1);

            wait_ARV_response();
        }