Hi everybody,
I was testing some sub to read and write 3 integers (6 bytes) using EEPROM.
The tests bring strange results:
If I write different ints the read before and after write are always the same.
Of course I'm missing something.
Here is code:
The log for this code is:
On previous try I put 77 88 99.
Anybody knows why?
Thank you.
Mauro Zanin
I was testing some sub to read and write 3 integers (6 bytes) using EEPROM.
The tests bring strange results:
If I write different ints the read before and after write are always the same.
Of course I'm missing something.
Here is code:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Public bc As ByteConverter
Dim eeprom As EEPROM
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
Dim res() As Int=readlastdate(0)
Log(res(0)," ",res(1)," ",res(2))
Log("AFTER")
writelastdate(0,Array As Int(11,22,33)) 'whatever values I put here I get always the same readout before and after write
Dim resi() As Int=readlastdate(0)
Log(resi(0)," ",resi(1)," ",resi(2))
End Sub
Sub readlastdate(off As Int)As Int()
Dim by() As Byte=eeprom.ReadBytes(64*off,6)
Dim dat() As Int=bc.IntsFromBytes(by)
Return dat
End Sub
Sub writelastdate(off As Int,data() As Int)
Dim by() As Byte=bc.IntsToBytes(data)
eeprom.WriteBytes(by, 64*off)
End Sub
The log for this code is:
B4X:
AppStart
11 22 33
AFTER
11 22 33
On previous try I put 77 88 99.
Anybody knows why?
Thank you.
Mauro Zanin