VEX V5 Python API
Public Member Functions | List of all members
vex.BrainSDCard Class Reference

Public Member Functions

def __init__ (self, parent)
 Use the SD Card class to load or save files on your SD card. More...
 
def is_inserted (self)
 Gets whether an SD card is inserted into the slot. More...
 
def filesize (self, filename)
 Gets the size of a file on the SD card, -1 on error (e.g. More...
 
def loadfile (self, filename, buffer)
 Loads a file from the SD card. More...
 
def load_to_bytearray (self, filename, size=None)
 Loads a file from the SD card into a new bytearray. More...
 
def load_to_string (self, filename, size=None)
 Loads a file from the SD card into a string. More...
 
def savefile (self, filename, buffer)
 Saves a file to the SD card. More...
 
def appendfile (self, filename, buffer)
 Appends data to an existing file. More...
 

Constructor & Destructor Documentation

◆ __init__()

def vex.BrainSDCard.__init__ (   self,
  parent 
)

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

Member Function Documentation

◆ is_inserted()

def vex.BrainSDCard.is_inserted (   self)

Gets whether an SD card is inserted into the slot.

Returns
True if the SD card is inserted, False othewise.

◆ filesize()

def vex.BrainSDCard.filesize (   self,
  filename 
)

Gets the size of a file on the SD card, -1 on error (e.g.

file does not exist)

Returns
the file size, in bytes
Parameters
filenamethe name of the file, use either '/' or '\' for directory separator.
Exceptions
anexception load failed (e.g. the file does not exist)

◆ loadfile()

def vex.BrainSDCard.loadfile (   self,
  filename,
  buffer 
)

Loads a file from the SD card.

Returns
the number of bytes read from the file.
Parameters
filenamethe name of the file, use either '/' or '\' for directory separator.
bufferpre-allocated bytearray of a fixed length that will be filled with file data.

◆ load_to_bytearray()

def vex.BrainSDCard.load_to_bytearray (   self,
  filename,
  size = None 
)

Loads a file from the SD card into a new bytearray.

Returns
a new bytearray containing the data
Parameters
filenamethe name of the file, use either '/' or '\' for directory separator.
size(optional) number of bytes to read. If omitted, will be equal to the file size.

◆ load_to_string()

def vex.BrainSDCard.load_to_string (   self,
  filename,
  size = None 
)

Loads a file from the SD card into a string.

Returns
a new string containing the file data
Parameters
filenamethe name of the file, use either '/' or '\' for directory separator.
size(optional) number of bytes to read. If omitted, will be equal to the file size.

◆ savefile()

def vex.BrainSDCard.savefile (   self,
  filename,
  buffer 
)

Saves a file to the SD card.

Returns
the number of bytes saved to the file.
Parameters
filenamethe name of the file, use either '/' or '\' for directory separator.
bufferdata to save, either a string or a byterray object
Exceptions
anexception if save failed (e.g. insufficient space)

◆ appendfile()

def vex.BrainSDCard.appendfile (   self,
  filename,
  buffer 
)

Appends data to an existing file.

Returns
the number of bytes saved to the file.
Parameters
filenamethe name of the file, use either '/' or '\' for directory separator.
bufferdata to append, either a string or a byterray object
Exceptions
anexception if save failed (e.g. insufficient space)