VEX V5 C++ API
Public Member Functions | List of all members
vex::brain::sdcard Class Reference

Use the SD Card class to load or save files on your SD card. More...

Public Member Functions

 sdcard ()
 
 ~sdcard ()
 
bool isInserted ()
 Gets the state of the SD card. More...
 
int32_t loadfile (const char *name, uint8_t *buffer, int32_t len)
 Loads a file from the SD card. More...
 
int32_t loadtextfile (const char *name, char *textBuffer, int32_t len)
 Loads a text file from the SD card. More...
 
int32_t filesize (const char *name)
 Get the size of a file on the SD card. More...
 
int32_t savefile (const char *name, uint8_t *buffer, int32_t len)
 Saves a file to the SD card. More...
 
int32_t savetextfile (const char *name, const char *text)
 Saves data to a text file. More...
 
int32_t appendfile (const char *name, uint8_t *buffer, int32_t len)
 Appends data to an existing file. More...
 
int32_t appendtextfile (const char *name, const char *text)
 Appends data to an existing text file. More...
 

Detailed Description

Use the SD Card class to load or save files on your SD card.

Constructor & Destructor Documentation

◆ sdcard()

vex::brain::sdcard::sdcard ( )

◆ ~sdcard()

vex::brain::sdcard::~sdcard ( )

Member Function Documentation

◆ isInserted()

bool vex::brain::sdcard::isInserted ( )

Gets the state of the SD card.

Returns
Returns true if the SD card is inserted. Returns false if there is not an SD card inserted.

◆ loadfile()

int32_t vex::brain::sdcard::loadfile ( const char *  name,
uint8_t *  buffer,
int32_t  len 
)

Loads a file from the SD card.

Returns
Returns the number of bytes read from the file.
Parameters
nameThe name of the file, use either '/' or '\' for directory separator.
bufferPointer to a buffer for file data.
lenThe length of the buffer in bytes. Usually set to the max length of the buffer.

◆ loadtextfile()

int32_t vex::brain::sdcard::loadtextfile ( const char *  name,
char *  textBuffer,
int32_t  len 
)

Loads a text file from the SD card.

Returns
returns the number of bytes read from the file.
Parameters
nameThe name of the file, use either '/' or '\' for directory separator.
textBuffera buffer for text data. Remember to allocate one extra byte for the null-terminator character (sdcard.filesize + 1).
lenThe length of the buffer in bytes. Usually set to the max length of the buffer.

◆ filesize()

int32_t vex::brain::sdcard::filesize ( const char *  name)

Get the size of a file on the SD card.

Returns
Returns the file size, in bytes
Parameters
nameThe name of the file, use either '/' or '\' for directory separator.

◆ savefile()

int32_t vex::brain::sdcard::savefile ( const char *  name,
uint8_t *  buffer,
int32_t  len 
)

Saves a file to the SD card.

Returns
Returns the number of bytes saved to the file.
Parameters
nameThe name of the file, use either '/' or '\' for directory separator.
bufferPointer to a buffer with file data.
lenThe length of the buffer in bytes. Usually set to the max length of the buffer.

◆ savetextfile()

int32_t vex::brain::sdcard::savetextfile ( const char *  name,
const char *  text 
)

Saves data to a text file.

Returns
the number of bytes saved to the file.
Parameters
nameThe name of the file, use either '/' or '\' for directory separator.
texta null-terminated C string to save.

◆ appendfile()

int32_t vex::brain::sdcard::appendfile ( const char *  name,
uint8_t *  buffer,
int32_t  len 
)

Appends data to an existing file.

Returns
Returns the number of bytes saved to the file.
Parameters
nameThe name of the file, use either '/' or '\' for directory separator.
bufferPointer to a buffer with file data.
lenThe length of the buffer in bytes. Usually set to the max length of the buffer.

◆ appendtextfile()

int32_t vex::brain::sdcard::appendtextfile ( const char *  name,
const char *  text 
)

Appends data to an existing text file.

Returns
the number of bytes saved to the file.
Parameters
nameThe name of the file, use either '/' or '\' for directory separator.
texta null-terminated C string to append.