Hey guys!
I was wondering if it’s possible if VexCode Pro V5 can open, read, write, and then close files. I’m not very sure if you can and I have been doing some searching around and I haven’t found anything relating to it. I know that PROS can read and write to files on an SD card that is plugged into the robot.
Thanks!
1 Like
Yes, there are examples here on the forum somewhere.
8 Likes
weilin
November 2, 2020, 4:48am
#3
Here’s a simple example showing how to use the VCS SD card save and load file API. This saves some information into a file called “test.h” on the SD card and then reads it back again.
#include "robot-config.h"
// storage for some information to save
uint8_t myTestData[ 100 ];
uint8_t myReadBuffer[ 1000 ];
int main() {
// set the test data to something detectable
for(int i=0;i<100;i++) {
myTestData* = i * 2;
}
// write test data to SD Card
int nWritten…
Not sure what you did there, only std::ofstream ofs; needs to be global
I just tried this in VCS and it works.
#include "robot-config.h"
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <fstream>
std::ofstream ofs;
int main() {
if( Brain.SDcard.isInserted() ) {
// create a file with long filename
ofs.open("a_long_filename_debug.txt", std::ofstream::out);
ofs << "lorem ipsum\r\n";
ofs << "this was a test of a file with long file name\r\n";
o…
4 Likes