EV3RT C API Reference [English]
An RTOS-based development platform for LEGO Mindstorms EV3.
 All Data Structures Functions Variables Enumerations Enumerator Groups
File system

Definitions of API for file system. More...

Data Structures

struct  memfile_t
 A memory file is a file stored in RAM rather than on the SD card. More...
 
struct  fileinfo_t
 Structure of file information. More...
 

Macros

#define TMAX_FILENAME_LEN   (255)
 Maximum length of a file name.
 

Enumerations

enum  serial_port_t {
  EV3_SERIAL_DEFAULT = 0,
  EV3_SERIAL_UART = 1,
  EV3_SERIAL_BT = 2
}
 Numbers representing serial ports. More...
 

Functions

ER_ID ev3_sdcard_opendir (const char *path)
 Open a directory for reading. More...
 
ER ev3_sdcard_readdir (ID dirid, fileinfo_t *p_fileinfo)
 Read file information in the directory. More...
 
ER ev3_sdcard_closedir (ID dirid)
 Close a directory. More...
 
ER ev3_memfile_load (const char *path, memfile_t *p_memfile)
 Create a memory file and load a specific file into it from the SD card. More...
 
ER ev3_memfile_free (memfile_t *p_memfile)
 Free the resource (memory) allocated to a memory file. More...
 
FILE * ev3_serial_open_file (serial_port_t port)
 Open the serial port as a file. More...
 
bool_t ev3_bluetooth_is_connected ()
 It is checked whether Bluetooth (Serial Port Profile) is connected. More...
 

Detailed Description

Definitions of API for file system.

This page describes only API unique to this platform, but it also supports file manipulation functions of standard C libraries such as fopen ().

Enumeration Type Documentation

Numbers representing serial ports.

Enumerator
EV3_SERIAL_DEFAULT 

Default serial port (port for log task)

EV3_SERIAL_UART 

UART (Sensor port 1)

EV3_SERIAL_BT 

Bluetooth SPP.

Function Documentation

bool_t ev3_bluetooth_is_connected ( )

It is checked whether Bluetooth (Serial Port Profile) is connected.

Return values
trueConnected. It can communicate with the Bluetooth virtual serial port.
falseUnconnected.
ER ev3_memfile_free ( memfile_t p_memfile)

Free the resource (memory) allocated to a memory file.

The buffer of p_memfile will be set to NULL on success.

Parameters
p_memfilePointer of a memory file to release
Return values
E_OKSuccess
E_PARThe p_memfile is NULL. [TODO: check - inconsistent with Jp version -> E_MACV]
E_OBJThe p_memfile does not point to a valid memory file.
ER ev3_memfile_load ( const char *  path,
memfile_t p_memfile 
)

Create a memory file and load a specific file into it from the SD card.

Generates an object of the memory file and reads the specified file from the SD card into this memory file. If an error occurs , clear buffer in p_memfile to NULL.

Parameters
pathPath of the file to be loaded
p_memfilePointer of save the created memory file
Return values
E_OKSuccess
E_MACVMemory access violation (path or p_memfile)
E_NOMEMNo enough free memory to create the memory file, or p_memfile is NULL. The buffer of p_memfile will be set to NULL if this happens.
E_PARThe path does not point to a valid file. The buffer of p_memfile will be set to NULL if this happens.
E_SYSI/O failure, which might be caused by a corrupted SD card. The buffer of p_memfile will be set to NULL if this happens.

Open file

Get file size & allocate memory

Perform reading

ER ev3_sdcard_closedir ( ID  dirid)

Close a directory.

If it succeeds, it releases the resource of the opened directory, and its ID can not be used.

Parameters
diridID of an opened directory
Return values
E_OKSuccess
E_CTXCall from non-task contest
E_IDInvalid ID number
E_SYSI/O error occurred (High possibility of SD card failure)
ER_ID ev3_sdcard_opendir ( const char *  path)

Open a directory for reading.

If it succeeds, it returns the ID of the opened directory as a return value. This ID can be used to obtain file information in the directory.

Parameters
pathPath of the directory to be opened
Return values
>0ID of the opened directory
E_CTXCall from non-task contest
E_MACVMemory access violation (path)
E_NOIDInsufficient ID number
E_PARInvalid path name
E_SYSI/O error occurred (High possibility of SD card failure)

dirent.h

ER ev3_sdcard_readdir ( ID  dirid,
fileinfo_t p_fileinfo 
)

Read file information in the directory.

Return information on the next file from the opened directory. [TODO: check]

Parameters
diridID of an opened directory
p_fileinfoPointer to structure with information of storing file [TODO: check].
Return values
E_OKSuccess
E_CTXCall from non-task contest
E_IDInvalid ID number
E_MACVMemory access violation (p_fileinfo)
E_OBJThere is no information on files that can be read any more
E_SYSI/O error occurred (High possibility of SD card failure)
FILE* ev3_serial_open_file ( serial_port_t  port)

Open the serial port as a file.

In case of failure, NULL is returned (error log is output).

Parameters
portSerial port number
Returns
Serial port file