Data Structures | Macros | Typedefs | Enumerations | Functions
Remote access

Remote access to the EV3 brick over UDP. More...

Data Structures

struct  EV3_MESSAGE_HEADER
 Header of an UDP message. More...
 
struct  EV3_MULTI_WRITE_SUBHEADER
 Sub-header for EV3_MULTI_WRITE. More...
 
struct  EV3_MESSAGE
 UDP message. More...
 

Macros

#define UDP_MESSAGE_LIMIT   1500
 
#define UDP_CLIENT_RX_TRIES   50
 
#define UDP_CLIENT_RX_WAIT   10 /* ms */
 
#define UDP_CLIENT_TX_TRIES   2
 
#define UDP_SERVER_RX_DELAY   1000 /* us */
 
#define UDP_SERVER_TX_DELAY   2000000
 
#define EOL   "\n"
 
#define ERR_PREF   "*** ERROR *** ev3_link: "
 
#define ERR_OUT(F, ...)
 
#define ERRNO_OUT(F, ...)
 

Typedefs

typedef struct EV3_MESSAGE_HEADERPEV3_MESSAGE_HEADER
 
typedef struct EV3_MULTI_WRITE_SUBHEADERPEV3_MULTI_WRITE_SUBHEADER
 
typedef struct EV3_MESSAGEPEV3_MESSAGE
 

Enumerations

enum  {
  EV3_IDLE = 0, EV3_WRITE_FILE = 1, EV3_RESULT_WRITE = 2, EV3_READ_FILE = 3,
  EV3_DATA_READ = 4, EV3_LIST_DIR = 5, EV3_DIRECTORY = 6, EV3_POWEROFF = 7,
  EV3_COMPLETION = 8, EV3_WELCOME = 9, EV3_READ_KEYS = 10, EV3_KEYS = 11,
  EV3_MULTI_WRITE = 12
}
 

Functions

int udp_ev3_open (char *addr, uint16_t port)
 Open an UDP socket. More...
 
int udp_ev3_close (void)
 Close an UDP socket. More...
 
int udp_ev3_write (char *fn, void *data, int sz)
 Write data into the specified file over UDP. More...
 
int udp_ev3_multi_write (uint8_t *sn, uint16_t pos, char *fn, void *data, int sz)
 Write data into the group of specified files over UDP. More...
 
int udp_ev3_read (char *fn, void *buf, int sz)
 Read data from the specified file over UDP. More...
 
int udp_ev3_read_keys (uint8_t *buf)
 Read state of EV3 brick keys over UDP. More...
 
int udp_ev3_listdir (char *fn, void *buf, int sz)
 List files in the specified directory over UDP. More...
 
int udp_ev3_catch_address (void)
 Check for a beacon from the EV3 brick. More...
 
int udp_ev3_poweroff (void)
 Power-off the EV3 brick. More...
 

Detailed Description

Remote access to the EV3 brick over UDP.

Macro Definition Documentation

#define ERR_OUT (   F,
  ... 
)
Value:
do { \
printf( EOL ERR_PREF F EOL, ## __VA_ARGS__ ); \
} while ( 0 )
#define ERRNO_OUT (   F,
  ... 
)
Value:
do { \
int e = errno; \
printf( EOL ERR_PREF F ": %s (%d)" EOL, ## __VA_ARGS__, strerror( e ), e ); \
} while ( 0 )

Enumeration Type Documentation

anonymous enum
Enumerator
EV3_WRITE_FILE 

File write command.

EV3_RESULT_WRITE 

Write result reply.

EV3_READ_FILE 

File read command.

EV3_DATA_READ 

Read data reply.

EV3_LIST_DIR 

List directory command.

EV3_DIRECTORY 

List directory reply.

EV3_POWEROFF 

Power-off the brick command.

EV3_COMPLETION 

Completion of work reply.

EV3_WELCOME 

A broadcast beacon.

EV3_READ_KEYS 

Keys read command.

EV3_KEYS 

Keys reply.

EV3_MULTI_WRITE 

Multi files write command.

Function Documentation

int udp_ev3_catch_address ( void  )

Check for a beacon from the EV3 brick.

Returns
0 - no beacon, 1 - beacon has been received.
int udp_ev3_close ( void  )

Close an UDP socket.

Returns
0 - finished successfully, EOF - an error has occurred.
int udp_ev3_listdir ( char *  fn,
void *  buf,
int  sz 
)

List files in the specified directory over UDP.

Parameters
fnDirectory name.
[out]bufBuffer for files list.
szBuffer size.
Returns
Count of read bytes.
int udp_ev3_multi_write ( uint8_t *  sn,
uint16_t  pos,
char *  fn,
void *  data,
int  sz 
)

Write data into the group of specified files over UDP.

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.
int udp_ev3_open ( char *  addr,
uint16_t  port 
)

Open an UDP socket.

Parameters
addrIP address of the EV3 brick.
portUDP port.
Returns
0 - finished successfully, EOF - an error has occurred.
int udp_ev3_poweroff ( void  )

Power-off the EV3 brick.

Returns
0 - no reply, 1 - OK.
int udp_ev3_read ( char *  fn,
void *  buf,
int  sz 
)

Read data from the specified file over UDP.

Parameters
fnFilename.
[out]bufBuffer for data.
szBuffer size.
Returns
Count of read bytes.
int udp_ev3_read_keys ( uint8_t *  buf)

Read state of EV3 brick keys over UDP.

Parameters
[out]bufBuffer for data.
Returns
Count of read bytes.
int udp_ev3_write ( char *  fn,
void *  data,
int  sz 
)

Write data into the specified file over UDP.

Parameters
fnFilename.
dataData.
szData size.
Returns
Count of written bytes.