Macros | Typedefs | Functions
File operations

Access to the file system of the EV3 brick. More...

Macros

#define Sleep(msec)   usleep(( msec ) * 1000 )
 
#define BRICK_WAIT_DELAY   1000 /* msec */
 
#define BRICK_WAIT_TRIES   10
 
#define STR_unknown_   "<unknown>"
 

Typedefs

typedef uint8_t byte
 
typedef uint32_t dword
 
typedef uint8_t INX_T
 
typedef uint8_t FLAGS_T
 

Functions

int ev3_init (void)
 Initialize the remote access and detect the EV3 brick. This function do nothing in the case of the local access. To disable the brick detection just specify IP address before the call of this function. More...
 
void ev3_uninit (void)
 Uninitialize the remote access.
 
size_t ev3_write_binary (const char *fn, char *data, size_t sz)
 Write binary data into the specified file of the EV3 brick. More...
 
size_t ev3_multi_write_binary (uint8_t *sn, uint16_t pos, const char *fn, char *data, size_t sz)
 Write binary data into several specified files of the EV3 brick. More...
 
size_t ev3_read_binary (const char *fn, char *buf, size_t sz)
 Read binary data from the specified file. More...
 
size_t ev3_read_keys (uint8_t *buf)
 Read state of the EV3 brick's keys. More...
 
bool ev3_poweroff (void)
 Power-off the EV3 brick. More...
 
size_t ev3_write (const char *fn, char *value)
 Write a string into the specified file. More...
 
size_t ev3_multi_write (uint8_t *sn, uint16_t pos, const char *fn, char *value)
 
size_t ev3_write_int (const char *fn, int value)
 Write an integer value into the specified file. More...
 
size_t ev3_multi_write_int (uint8_t *sn, uint16_t pos, const char *fn, int value)
 
size_t ev3_write_dword (const char *fn, uint32_t value)
 Write an unsigned integer value into the specified file. More...
 
size_t ev3_multi_write_dword (uint8_t *sn, uint16_t pos, const char *fn, uint32_t value)
 
size_t ev3_write_float (const char *fn, float value)
 Write a float value into the specified file. More...
 
size_t ev3_multi_write_float (uint8_t *sn, uint16_t pos, const char *fn, float value)
 
size_t ev3_write_bool (const char *fn, bool value)
 Write a boolean value into the specified file. More...
 
size_t ev3_multi_write_bool (uint8_t *sn, uint16_t pos, const char *fn, bool value)
 
size_t ev3_write_byte (const char *fn, uint8_t value)
 Write a byte value into the specified file. More...
 
size_t ev3_multi_write_byte (uint8_t *sn, uint16_t pos, const char *fn, uint8_t value)
 
size_t ev3_write_char_array (const char *fn, char *value)
 
size_t ev3_multi_write_char_array (uint8_t *sn, uint16_t pos, const char *fn, char *value)
 
size_t ev3_write_byte_array (const char *fn, uint8_t *value, size_t sz)
 
size_t ev3_multi_write_byte_array (uint8_t *sn, uint16_t pos, const char *fn, uint8_t *value, size_t sz)
 
size_t ev3_read (const char *fn, char *buf, size_t sz)
 Read a string from the specified file. More...
 
size_t ev3_read_int (const char *fn, int *buf)
 Read an integer value from the specified file. More...
 
size_t ev3_read_dword (const char *fn, uint32_t *buf)
 Read an unsigned integer value from the specified file. More...
 
size_t ev3_read_float (const char *fn, float *buf)
 Read a float value from the specified file. More...
 
size_t ev3_read_bool (const char *fn, bool *buf)
 Read a boolean value from the specified file. More...
 
size_t ev3_read_byte (const char *fn, uint8_t *buf)
 Read a byte value from the specified file. More...
 
size_t ev3_read_char_array (const char *fn, char *buf, size_t sz)
 
size_t ev3_read_byte_array (const char *fn, uint8_t *buf, size_t sz)
 
size_t ev3_listdir (const char *fn, char *buf, size_t sz)
 List files in the specified directory of the EV3 brick. More...
 
int ev3_string_suffix (const char *prefix, char **s, uint32_t *buf)
 Get a numerical suffix of the string. More...
 
 EV3_VAR_INIT (char *ev3_brick_addr, NULL)
 Predefined IP address of the EV3 brick.
 
 EV3_VAR_INIT (uint16_t ev3_brick_port, 8800)
 UDP port of the EV3 brick.
 

Detailed Description

Access to the file system of the EV3 brick.

This module contains functions for the local access to the file system of the EV3 brick, in case of the remote access appropriate functions from ev3_link module will be called.

Function Documentation

int ev3_init ( void  )

Initialize the remote access and detect the EV3 brick. This function do nothing in the case of the local access. To disable the brick detection just specify IP address before the call of this function.

Returns
0 - the brick is NOT found or auto-detection is disabled; 1 - the brick is found; -1 - an error has occurred.
Examples:
dc.c, drive.c, hello.c, io.c, light.c, port.c, poweroff.c, rcx_led.c, sensor.c, servo.c, tacho.c, and tacho.cpp.
size_t ev3_listdir ( const char *  fn,
char *  buf,
size_t  sz 
)

List files in the specified directory of the EV3 brick.

Parameters
fnDirectory name.
[out]bufBuffer for files list.
szBuffer size.
Returns
Count of read bytes.
Examples:
io.c.
size_t ev3_multi_write_binary ( uint8_t *  sn,
uint16_t  pos,
const char *  fn,
char *  data,
size_t  sz 
)

Write binary data into several specified files of the EV3 brick.

Parameters
snVector of sequence numbers ending with DESC_LIMIT.
posPosition of the sequence number field into the template.
fnFilename template.
dataData.
szData size.
Returns
Count of written bytes.
bool ev3_poweroff ( void  )

Power-off the EV3 brick.

Returns
false - no reply; true - OK.
Examples:
poweroff.c.
size_t ev3_read ( const char *  fn,
char *  buf,
size_t  sz 
)

Read a string from the specified file.

Parameters
fnFilename.
[out]bufBuffer for string.
szBuffer size.
Returns
Count of read bytes.
size_t ev3_read_binary ( const char *  fn,
char *  buf,
size_t  sz 
)

Read binary data from the specified file.

Parameters
fnFilename.
[out]bufBuffer for data.
szBuffer size.
Returns
Count of read bytes.
size_t ev3_read_bool ( const char *  fn,
bool *  buf 
)

Read a boolean value from the specified file.

Parameters
fnFilename.
[out]bufBuffer for a value.
Returns
Count of read bytes.
size_t ev3_read_byte ( const char *  fn,
uint8_t *  buf 
)

Read a byte value from the specified file.

Parameters
fnFilename.
[out]bufBuffer for a value.
Returns
Count of read bytes.
size_t ev3_read_dword ( const char *  fn,
uint32_t *  buf 
)

Read an unsigned integer value from the specified file.

Parameters
fnFilename.
[out]bufBuffer for a value.
Returns
Count of read bytes.
size_t ev3_read_float ( const char *  fn,
float *  buf 
)

Read a float value from the specified file.

Parameters
fnFilename.
[out]bufBuffer for a value.
Returns
Count of read bytes.
size_t ev3_read_int ( const char *  fn,
int *  buf 
)

Read an integer value from the specified file.

Parameters
fnFilename.
[out]bufBuffer for a value.
Returns
Count of read bytes.
Examples:
io.c.
size_t ev3_read_keys ( uint8_t *  buf)

Read state of the EV3 brick's keys.

Parameters
[out]bufBuffer for a state.
Returns
Count of read bytes.
Examples:
drive.c, and sensor.c.
int ev3_string_suffix ( const char *  prefix,
char **  s,
uint32_t *  buf 
)

Get a numerical suffix of the string.

Parameters
prefixPrefix string.
sin - pointer to the string (char *); out - pointer to the next character after the suffix.
[out]bufBuffer for a numerical suffix.
Returns
0 - suffix is not found; 1 - suffix is found at the string end; 2 - suffix is found but the string is not over.
size_t ev3_write ( const char *  fn,
char *  value 
)

Write a string into the specified file.

Parameters
fnFilename.
valueValue.
Returns
Count of written bytes.
size_t ev3_write_binary ( const char *  fn,
char *  data,
size_t  sz 
)

Write binary data into the specified file of the EV3 brick.

Parameters
fnFilename.
dataData.
szData size.
Returns
Count of written bytes.
size_t ev3_write_bool ( const char *  fn,
bool  value 
)

Write a boolean value into the specified file.

Parameters
fnFilename.
valueValue.
Returns
Count of written bytes.
size_t ev3_write_byte ( const char *  fn,
uint8_t  value 
)

Write a byte value into the specified file.

Parameters
fnFilename.
valueValue.
Returns
Count of written bytes.
size_t ev3_write_dword ( const char *  fn,
uint32_t  value 
)

Write an unsigned integer value into the specified file.

Parameters
fnFilename.
valueValue.
Returns
Count of written bytes.
size_t ev3_write_float ( const char *  fn,
float  value 
)

Write a float value into the specified file.

Parameters
fnFilename.
valueValue.
Returns
Count of written bytes.
size_t ev3_write_int ( const char *  fn,
int  value 
)

Write an integer value into the specified file.

Parameters
fnFilename.
valueValue.
Returns
Count of written bytes.
Examples:
io.c.