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... | |
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 ().
enum serial_port_t |
bool_t ev3_bluetooth_is_connected | ( | ) |
It is checked whether Bluetooth (Serial Port Profile) is connected.
true | Connected. It can communicate with the Bluetooth virtual serial port. |
false | Unconnected. |
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.
p_memfile | Pointer of a memory file to release |
E_OK | Success |
E_PAR | The p_memfile is NULL. [TODO: check - inconsistent with Jp version -> E_MACV] |
E_OBJ | The 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.
path | Path of the file to be loaded |
p_memfile | Pointer of save the created memory file |
E_OK | Success |
E_MACV | Memory access violation (path or p_memfile) |
E_NOMEM | No 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_PAR | The path does not point to a valid file. The buffer of p_memfile will be set to NULL if this happens. |
E_SYS | I/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.
dirid | ID of an opened directory |
E_OK | Success |
E_CTX | Call from non-task contest |
E_ID | Invalid ID number |
E_SYS | I/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.
path | Path of the directory to be opened |
>0 | ID of the opened directory |
E_CTX | Call from non-task contest |
E_MACV | Memory access violation (path) |
E_NOID | Insufficient ID number |
E_PAR | Invalid path name |
E_SYS | I/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]
dirid | ID of an opened directory |
p_fileinfo | Pointer to structure with information of storing file [TODO: check]. |
E_OK | Success |
E_CTX | Call from non-task contest |
E_ID | Invalid ID number |
E_MACV | Memory access violation (p_fileinfo) |
E_OBJ | There is no information on files that can be read any more |
E_SYS | I/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).
port | Serial port number |