Update ... I decided to save file as binary instead of plain hex text I also added prompt window which asks when memory is greater than 512kb if you would like to show data in grid view because I was unable to speed up populating process and it takes to much time to show data in grid view if eeprom memory is greater than 512kb.
I got it slightly faster but it still takes to much time so now you have an option
Im facing now another problem, somehow im getting to much of bytes from eeprom, I cant get it how. Im trying to debug it but cant find cause. I think that serial communication is to blame..
Write and read from file returns exact value of bytes so it is not issue in reading and writing the file
I was looking what arduino and eeprom talks about and didn't find problems there so it seems that windows application makes all this trouble.
Here is arduino and visual studio part of code used to communicate to each other
From image above it is clear that arduino understood how many bytes should read otherwise it would trigger an error message "Arduino didn't acknowledge sent data packet" and indeed arduino reads epprom exact number of times, verified by analyzer.
Now I see that I misspelled "acknowledge" in code
Here is an image of reading the same memory with the same settings
I would understand if they lose some packets while communicating but adding "some" random number of reads extra. I don't get it
Here is visual basic code fully commented "this part is used to receive bytes from arduino"
Dim Magic_Byte As String = "" 'not part of this code
Com_port_received_text = "" 'if anithing has been sent over serial get rid of it
Dim DataArray As New ArrayList 'everything sent from arduino goes to this array
Dim i As String = "" 'not part of this code
Do
If Not Com_port_received_text = "" Then 'if something was received
SaveArray.Add(Com_port_received_text) 'Add received text to array -> it will look like this
'SaveArray(0) = "7h90h17h49h73h96h84h136h86h153h9"
'I can get only one byte over serial but I need to add
'delay(2); to slow down arduino transmission, vb app
'can handle this string without slowing arduino down
Com_port_received_text = "" 'clear variable
End If
Application.DoEvents() 'cant monitor serial protocol while
'executing do loop without this
Loop Until Com_port_received_text = "X" 'When arduino sends X it means that transmission
'is done
Dim newarray As New ArrayList 'here I will save actual data received from serial
For Each Data As String In SaveArray 'Loop trough SaveArray until end, first pass will
'hold '"7h90h17h49h73h96h84h136h86h153h9"
Dim parts1() As String = Split(Data, "h") 'Data will hold "7h90h17h49h73h96h84h136h86h153h9" and
'parts1()is an array and it will be same string but
'without h character like part1(0)= 7, part1(1) = 90
'and so on
For Each Part As String In parts1 'goes trough part1 array and gets string out of it
newarray.Add(Part) 'stores that string to new array, it will look same
'as in parts1() array but this array can handle
'strings, integers, longs and is easier to handle
'data in it
Next
Next
SaveArray.Clear() 'Empty SaveArray " for later use"
For Each Part As String In newarray 'read newarray which already holds wrong number of
'bytes
If Not Part = "" Then 'used to avoid exception throw
SaveArray.Add((Convert.ToInt16(Part))) 'this array is used to write binary file
DataArray.Add(Hex(Convert.ToInt32(Part))) 'and this one is used to populate grid view
End If
Next
Here is arduino part
shiftOut(si_pin, sck, MSBFIRST, readR); //Start comminucation from eeprom (readR) = read opcode
shiftOut(si_pin, sck, MSBFIRST, 0); //send first 8 bytes of address
shiftOut(si_pin, sck, MSBFIRST, 0); //send second 8 bytes of address
Serial.print(shiftIn(so_pin, sck, MSBFIRST)); //Read 0x000000 addres of eeprom and send it over serial
Serial.print("h"); //Send h over serial to know where to split the string
//in visual basic
do{
String var = "h";
byte ii = shiftIn(so_pin, sck, MSBFIRST); //receive second address from eeprom
Serial.print(ii); //send it over serial
Serial.print("h"); //Send h over serial to know where to split the string
ii = '\0'; // I was thinking that maybe ii buffer hold some data
//and I get extra data sent over serial so I tried to
//flush ii buffer with '\0' .. . but no help at all
i++; //holds number of addresses readed
} while(i != address_length); //loop until end of eeprom in this case 0x5ffff
Hope that someone can find out what I'm missing here.
I tried also slowing down communication between arduino and computer but didn't get any improvement, also if i read only until 0x1ff or 0xfff everything works fine. it smells like I declared some variable as wrong type but I triple checked that and didn't find any problems there.