General area when it fits no where else

Moderator: Mmiscool

User avatar
By kennedyd
#38990 Great to see a BASIC interpreter on the ESP8266! Last BASIC interpreter I played with was ages ago on the 8051.

The setup notes and flasher got me up & running very quickly.

Trying to work out how to persist data to the flash area on the ESP. The docs relating to File I/O are clear enough but don't seems to show any examples.

I tried a 'writer' program of

print "Writing data"
write "myfile" "ABC123"
print "Written"

followed by another program ...

print "Reader"
read "myfile" a$
print a$

However, the read value for a$ didn't reflect what I thought that I'd written.

Probably just me making some simple error.

Any advice most welcome.

Derek.
User avatar
By Mmiscool
#39001 I just tested your code.

Code: Select allprint "Writing data"
write "myfile" "ABC123"
print "Written"

print "Reader"
read "myfile" a$
print a$


It seemed to read the data just fine.

I ran the code to write the data. Then I ran the code to read the data.

The output from the basic interpreter was as follows.
Code: Select allReader
ABC123
Done...


What size is your flash. You may want to see how much flash space is remaining and the serial output to see if there are any failures for the read or write.

Also try resetting the module and try running the code again.
User avatar
By kennedyd
#39034 Thanks for the independent test.

I'm using an ESP-12 module. When flashing ESPBasic onto the module, I selected 1M as the flash size.
flashfree()_ returns 474139

I didn't realise that there was debug info on the serial port! Thanks for pointing this out. No errors reported.

Followed your advice and reset the module. Having done the reset, and re-run 'writer' followed by 'reader' ... it worked. However, it only worked for the first attempt. Subsequent executions, with a different string being written, read back as the original string.

Not sure if some sort of 'flush' command is needed to force the new string to overwrite the previous one?

On my module, the following code prints the same value for a$ after each read operation.

print "Writing data"
write "myfile1" "9876543"
print "Written"
print "Reading data"
read "myfile1" a$
print a$

print "Writing data"
write "myfile1" "ABCDEF"
print "Written"
print "Reading data"
read "myfile1" a$
print a$
User avatar
By luc VdV
#39039 MEMCLEAR should do it. Now it returns ABCDEF on the 2nd read.
Code: Select allmemclear
print "Writing data"
write "myfile1" "9876543"
print "Written"
print "Reading data"
read "myfile1" a$
print a$

memclear
print "Writing data"
write "myfile1" "ABCDEF"
print "Written"
print "Reading data"
read "myfile1" a$
print a$