Saving information to the Vex Cortex

I am wanting a way to save the last used autonomous function so that when ever we restart the robot it will use that unless it gets changed. As I have a read there seems to be no way to read or write from a text file that is located on the Cortex. I was wondering if that was true and if so is there other ways to save small pieces of information to the Cortex.

You could just use a potentiometer autonomous selector, so if you leave the potentiometer in the same position it will use the same program.

I would do this, however, I was wanting a way to do it purely from the programming side of things. I will probably fall back to this if need be, but I like the idea of having information saved to the brain itself since that opens up a world of possibilities

Have a look at this post.

The demo code is here.

use with care.

Hi jpearman,

Looking over (actually got/implemented/tested) your excellent rcfs code. Thanks for showing it’s possible and making it work!

I’m using it straightforward, even tried the sample provided.

I assume that RobotC 4.56 (9134) (F/W 10.56) perhaps changed the header size again, so that it writes garbage from the add_file. Also, what’s the best way to overwrite a file (or delete, even if through the GUI)? It is really to only download fw again? (I’ve been reading up on all the threads).

For this to work for me, would you recommend my trying a few rcfs changes, or reverting to a specific previous version of RobotC (not sure if those still exist tho).

-Jim Gale

I’ll have to fire up a cortex and see what’s happening now, if it’s broken it should be a simple fix. I will look later today or tomorrow.

Thank you /so/ much, that would incidentally allow my team to learn/adopt and potentially use it for their competition :slight_smile:

Well, seems to work ok for me here with ROBOTC 4.56, here was the output from the demo code after saving a few files.

flashFileDemo    Addr 08018800 Data 08018818 Size  7438 Type 01 Time 5BF1EB35
debug001         Addr 08030000 Data 08030018 Size  1024 Type 05 Time 38640900
debug002         Addr 08030418 Data 08030430 Size  1024 Type 05 Time 38640900
debug003         Addr 08030830 Data 08030848 Size  1024 Type 05 Time 38640900
myfile           Addr 08030C48 Data 08030C60 Size  1024 Type 05 Time 38640900
last file written was myfile
data ptr is 08030C60
length is 00000400
the file starts like this ...
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 

you can delete files using the file management dialog, attached is a screen shot showing the same files saved on the cortex.

ok, maybe I need to reflash then for it to work… no matter how many times I write any file name, it keeps the file name of the first file I ever wrote - and the ‘data’ of the file shows multiple file headers of that same original file name, as well as junk - not the original data at all. I’ll try a flash and retry.

Thanks for checking.

Nope, still getting this… (this was after your sample, but ‘abcdf’ was my file that I deleted from my code) - kept my name but your file size…

flashFileDemo    Addr 08018800 Data 08018818 Size  3768 Type 01 Time 5BF1F001
abcdf            Addr 08030000 Data 08030018 Size  1024 Type 05 Time 38640900
last file written was abcdf
data ptr is 08030018
length is 00000400
the file starts like this ...

send me the code you are running, if the concern are the FFFFFFB0 entries, they are probably just negative numbers.

that got me thinking -> and WORKING -> I had an unsigned char buffer, rather than a static char buffer. Not sure which (signed vs static (I assume static)) did it, but it works now through power off!

Thank you!!!