diff --git a/FlashProgrammer/WindowsFormsApp1/Form1.Designer.cs b/FlashProgrammer/WindowsFormsApp1/Form1.Designer.cs index 04f7475..d57b004 100644 --- a/FlashProgrammer/WindowsFormsApp1/Form1.Designer.cs +++ b/FlashProgrammer/WindowsFormsApp1/Form1.Designer.cs @@ -166,7 +166,7 @@ private void InitializeComponent() this.txtMessages.Multiline = true; this.txtMessages.Name = "txtMessages"; this.txtMessages.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtMessages.Size = new System.Drawing.Size(681, 85); + this.txtMessages.Size = new System.Drawing.Size(681, 306); this.txtMessages.TabIndex = 11; // // label3 @@ -247,7 +247,7 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(715, 546); + this.ClientSize = new System.Drawing.Size(715, 770); this.Controls.Add(this.button1); this.Controls.Add(this.btnClearLog); this.Controls.Add(this.btnClearData); diff --git a/FlashProgrammer/WindowsFormsApp1/Form1.cs b/FlashProgrammer/WindowsFormsApp1/Form1.cs index fe94b9c..e448d57 100644 --- a/FlashProgrammer/WindowsFormsApp1/Form1.cs +++ b/FlashProgrammer/WindowsFormsApp1/Form1.cs @@ -32,7 +32,7 @@ public Form1() private void Form1_Load(object sender, EventArgs e) { //Find last com port and list it in the control. - + _continue = false; } private void AddToMessageLog(string textToAdd) @@ -87,6 +87,8 @@ private void Serial_DataReceived(object sender, SerialDataReceivedEventArgs e) //try //{ string data = serial.ReadLine(); //This line is problematic and maybe should be serial.ReadBytes??? + if (data.StartsWith("OK")) + _continue = true; if (data.StartsWith("0x")) this.BeginInvoke(new SetTextDeleg(SerialIn_DataReceived), new object[] { data }); else @@ -171,7 +173,7 @@ private void btnWrite_Click(object sender, EventArgs e) string WriteFileToFlash(string filename) { string result = "FAILED!"; - + //Open the file and read into a byte array byte[] dataArray = File.ReadAllBytes(filename); @@ -182,32 +184,37 @@ string WriteFileToFlash(string filename) txtMessages.Text += "Writing Flash starting at address 0x0000. Please Wait..."; int addressCounter = 0; - //send then where x is 256 or the number of bytes to write, lastly send and then the full amount of bytes in sequence + //send then where x is 256 or the number of bytes to write, lastly send and then the full amount of bytes in sequence //- Arduino side seems to work just need this side to int totalSize = dataArray.Length; serial.WriteLine(""); - serial.WriteLine(""); + serial.WriteLine(""); serial.Write(""); int offset = 0; - int block = 256; + int block = 50; if (block > totalSize) block = totalSize; //This part needs checking before allowing a write to Flash!!!!!!! while(offset < totalSize) - { + { + _continue = false; + if ((offset + block) > totalSize) + block = totalSize - offset; serial.Write(dataArray, offset, block); if (offset + block > totalSize) offset = totalSize - (offset + block); else offset += block; - Application.DoEvents(); + + while(_continue == false) + Application.DoEvents(); } //Read the bytes back and compare, using a dump command, ignore and don't read data past where it was written... - return "Success: Wrote " + (addressCounter + 1).ToString() + " bytes to Flash." + Environment.NewLine; + return "Success: Wrote " + totalSize.ToString() + " bytes to Flash." + Environment.NewLine; } private void btnErase_Click(object sender, EventArgs e) diff --git a/FlashProgrammer/WindowsFormsApp1/bin/Debug/WindowsFormsApp1.exe b/FlashProgrammer/WindowsFormsApp1/bin/Debug/WindowsFormsApp1.exe index aec491f..c1f6379 100644 Binary files a/FlashProgrammer/WindowsFormsApp1/bin/Debug/WindowsFormsApp1.exe and b/FlashProgrammer/WindowsFormsApp1/bin/Debug/WindowsFormsApp1.exe differ diff --git a/FlashProgrammer/WindowsFormsApp1/bin/Debug/WindowsFormsApp1.pdb b/FlashProgrammer/WindowsFormsApp1/bin/Debug/WindowsFormsApp1.pdb index 7570f54..dd9b2df 100644 Binary files a/FlashProgrammer/WindowsFormsApp1/bin/Debug/WindowsFormsApp1.pdb and b/FlashProgrammer/WindowsFormsApp1/bin/Debug/WindowsFormsApp1.pdb differ diff --git a/FlashProgrammer/WindowsFormsApp1/obj/Debug/WindowsFormsApp1.csproj.GenerateResource.cache b/FlashProgrammer/WindowsFormsApp1/obj/Debug/WindowsFormsApp1.csproj.GenerateResource.cache index d647e13..cd7bcc5 100644 Binary files a/FlashProgrammer/WindowsFormsApp1/obj/Debug/WindowsFormsApp1.csproj.GenerateResource.cache and b/FlashProgrammer/WindowsFormsApp1/obj/Debug/WindowsFormsApp1.csproj.GenerateResource.cache differ diff --git a/FlashProgrammer/WindowsFormsApp1/obj/Debug/WindowsFormsApp1.exe b/FlashProgrammer/WindowsFormsApp1/obj/Debug/WindowsFormsApp1.exe index aec491f..c1f6379 100644 Binary files a/FlashProgrammer/WindowsFormsApp1/obj/Debug/WindowsFormsApp1.exe and b/FlashProgrammer/WindowsFormsApp1/obj/Debug/WindowsFormsApp1.exe differ diff --git a/FlashProgrammer/WindowsFormsApp1/obj/Debug/WindowsFormsApp1.pdb b/FlashProgrammer/WindowsFormsApp1/obj/Debug/WindowsFormsApp1.pdb index 7570f54..dd9b2df 100644 Binary files a/FlashProgrammer/WindowsFormsApp1/obj/Debug/WindowsFormsApp1.pdb and b/FlashProgrammer/WindowsFormsApp1/obj/Debug/WindowsFormsApp1.pdb differ