The savefile method cannot be used with 2d arrays. You will need to manually save to the files using loops and such. I recommend using file streams for this.
so basically im writing code that it reads the drivers input every time they move, and then it saves it to a 2d array, then it saves that array to a file. then when you run auton, it loads the 2d array again and redoes all the functions, exactly as the driver did. its possible, as another team in our school did it, but it took them 3 months to make work. however, im actually doing quite well right now. it seems to work very well at the moment because i made an improved system of tracking it, which i believe they did not have. however they refuse to share their code for some reason. they call it a shadow auton. so im replicating their thing, and the last part of the puzzle i need now is it loading the array, and from there my program takes it away.
The dumbed down way (ie. without using more standard C or C++ file access calls) is to just use loadfile, pass it the same buffer pointer and max size and it will just read in that data if it is available.
/**
* @return Returns the number of bytes read from the file.
* @brief Loads a file from the SD card.
* @param name The name of the file.
* @param buffer Pointer to a buffer for file data.
* @param len The length of the buffer in bytes. Usually set to the max length of the buffer.
*/
int32_t loadfile(const char *name, uint8_t *buffer, int32_t len );
/**
* @brief Saves a file to the SD card.
* @return Returns the number of bytes saved to the file.
* @param name The name of the file.
* @param buffer Pointer to a buffer with file data.
* @param len The length of the buffer in bytes. Usually set to the max length of the buffer.
*/
int32_t savefile(const char *name, uint8_t *buffer, int32_t len );
To give a simplified answer, a buffer tells the computer to set aside memory, in bytes, for an object (objects like ints, strings, streams, arrays, etc).
Grab a cup. That “space” inside the cup is like a buffer. If you fill the cup with water, as long as the amount of water is <= the size of the cup you are fine. But as soon as the amount of water is greater than the size of the cup then the water will overflow. As long as the size you declare as the buffer is greater than the size of the objects you put in it you’ll be okay. But as soon as the size of the object exceeds the buffer, then you’ll get an “overflow error.”
shadow_auton is the array. im not sure why i have that as the buffer. so i relace that with my variable myReadBuffer and then i just have to sit back and let C++ do its thing? i see a * in there. i believe thats a pointer. What is this file that it’s saving? Is it saving my array or not?