Data Structures | Macros | Typedefs | Enumerations | Functions
ev3_link.c File Reference

EV3 remote access. More...

#include <stdlib.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
#include <dirent.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <arpa/inet.h>
#include "ev3_link.h"
#include "../ev3_both.h"

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 Sleep(msec)   usleep(( msec ) * 1000 )
 
#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

EV3 remote access.

Author
Vitaly Kravtsov (in4li.nosp@m.o@gm.nosp@m.ail.c.nosp@m.om)