Remote access to the EV3 brick over UDP.
More...
|
#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, ...) |
|
|
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
} |
|
|
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...
|
|
Remote access to the EV3 brick over UDP.
#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 )
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.
|
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
-
| fn | Directory name. |
[out] | buf | Buffer for files list. |
| sz | Buffer 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
-
sn | Vector of sequence numbers ending with DESC_LIMIT. |
pos | Position of the sequence number field into the template. |
fn | Filename template. |
data | Data. |
sz | Data size. |
- Returns
- Count of written bytes.
int udp_ev3_open |
( |
char * |
addr, |
|
|
uint16_t |
port |
|
) |
| |
Open an UDP socket.
- Parameters
-
addr | IP address of the EV3 brick. |
port | UDP 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
-
| fn | Filename. |
[out] | buf | Buffer for data. |
| sz | Buffer size. |
- Returns
- Count of read bytes.
int udp_ev3_read_keys |
( |
uint8_t * |
buf | ) |
|
Read state of EV3 brick keys over UDP.
- Parameters
-
- Returns
- Count of read bytes.
int udp_ev3_write |
( |
char * |
fn, |
|
|
void * |
data, |
|
|
int |
sz |
|
) |
| |
Write data into the specified file over UDP.
- Parameters
-
fn | Filename. |
data | Data. |
sz | Data size. |
- Returns
- Count of written bytes.