ev3duder  0.3.0
EV3 Downloader/Uploader
main.c File Reference

Argument parsing, device opening and file creation/openning. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <wchar.h>
#include <errno.h>
#include <hidapi/hidapi.h>
#include "btserial.h"
#include "tcp.h"
#include "ev3_io.h"
#include "defs.h"
#include "packets.h"
#include "error.h"
#include "funcs.h"

Go to the source code of this file.

Macros

#define MAIN
 For avoiding the need to separately define and declare stuff. More...
 
#define assert(cond)   do{ if (!(cond)) {if (handle) ev3_close(handle);exit(ERR_ARG);}}while(0)
 
#define VendorID   0x694
 LEGO GROUP. More...
 
#define ProductID   0x005 /* EV3 */
 EV3. More...
 
#define ExecName   "/tmp/Executing shell cmd.rbf"
 Filename used for executing command with exec More...
 
#define FOREACH_ARG(ARG)
 
#define MK_ENUM(x)   ARG_##x,
 
#define MK_STR(x)   #x,
 
#define SANITIZE
 

Enumerations

enum  ARGS { FOREACH_ARG =(MK_ENUM) }
 

Functions

int main (int argc, char *argv[])
 

Variables

const char *const usage
 
const char *const usage_desc
 

Detailed Description

Argument parsing, device opening and file creation/openning.

Author
Ahmad Fatoum

Definition in file main.c.

Macro Definition Documentation

#define assert (   cond)    do{ if (!(cond)) {if (handle) ev3_close(handle);exit(ERR_ARG);}}while(0)

Definition at line 17 of file main.c.

#define ExecName   "/tmp/Executing shell cmd.rbf"

Filename used for executing command with exec

Definition at line 34 of file main.c.

#define FOREACH_ARG (   ARG)
Value:
ARG(info) \
ARG(up) \
ARG(dl) \
ARG(run) \
ARG(ls) \
ARG(rm) \
ARG(mkdir) \
ARG(mkrbf) \
ARG(tunnel) \
ARG(listen) \
ARG(send) \
ARG(exec) \
ARG(wpa2) \
ARG(nop) \
ARG(end)
int ls(const char *rem)
list contents of remote directory rem
Definition: ls.c:36
int info(const char *arg)
print connection information, beep and exit
Definition: info.c:36
int send()
Definition: send.c:6
int listen()
Definition: listen.c:7
int dl(const char *path, FILE *fp)
download remote source rem to local file loc
Definition: dl.c:26
int run(const char *rem, unsigned timeout)
run remote .rbf file rem via VM
Definition: run.c:30
int up(FILE *loc, const char *rem)
upload local file loc to remote destination rem
Definition: up.c:29
int rm(const char *rem)
remove remote file or directory rem
Definition: rm.c:27
int mkdir(const char *rem)
create directory rem on remote system
Definition: mkdir.c:29
int tunnel()
tunnel stdio to established ev3 connection
Definition: tunnel.c:35
size_t mkrbf(char **buf, const char *cmd)
fill *buf with a rbf file executing cmd
Definition: mkrbf.c:29

Definition at line 86 of file main.c.

#define MAIN

For avoiding the need to separately define and declare stuff.

Definition at line 7 of file main.c.

#define MK_ENUM (   x)    ARG_##x,

Definition at line 103 of file main.c.

#define MK_STR (   x)    #x,

Definition at line 104 of file main.c.

#define ProductID   0x005 /* EV3 */

EV3.

Definition at line 32 of file main.c.

#define SANITIZE

Definition at line 113 of file main.c.

#define VendorID   0x694

LEGO GROUP.

Definition at line 30 of file main.c.

Enumeration Type Documentation

enum ARGS
Enumerator
FOREACH_ARG 

Definition at line 105 of file main.c.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 129 of file main.c.

Variable Documentation

unsigned hid

Definition at line 117 of file main.c.

unsigned select

Definition at line 116 of file main.c.

unsigned serial

Definition at line 118 of file main.c.

char* serial_id[2]

Definition at line 124 of file main.c.

unsigned tcp

Definition at line 119 of file main.c.

char* tcp_id

Definition at line 123 of file main.c.

unsigned timeout

Definition at line 126 of file main.c.

const char* const usage
Initial value:
=
"USAGE: ev3duder " "[ --tcp | --usb | --serial ] [=dev1,dev2] \n"
" " "[ up loc rem | dl rem loc | rm rem | ls [rem] |\n"
" " " mkdir rem | mkrbf rem loc | run rem | exec cmd |\n"
" " " wpa2 SSID [pass] | info | tunnel ]\n"
" "
"rem = remote (EV3) path, loc = local path, dev = device identifier" "\n"

Definition at line 60 of file main.c.

const char* const usage_desc
Initial value:
=
" up\t" "upload local file to remote ev3 brick\n"
" dl\t" "download remote file to local system\n"
" rm\t" "remove file on ev3 brick\n"
" ls\t" "list files. Standard value is '/'\n"
" info\t" "attempt a beep and print information about the connection\n"
" mkdir\t" "create directory. Relative to path of VM.\n"
" mkrbf\t" "create rbf (menu entry) file locally. Sensible upload paths are:\n"
"\t" "\t../prjs/BrkProg_SAVE/ Internal memory\n"
"\t" "\t../prjs/BrkProg_DL/ Internal memory\n"
"\t" "\t./apps/ Internal memory - Applicatios (3rd tab)\n"
"\t" "\t/media/card/myapps/ Memory card\n"
"\t" "\t/media/usb/myappps/ USB stick\n"
"run\t" "instruct the VM to run a rbf file\n"
"exec\t" "pass cmd to root shell. Handle with caution\n"
"wpa2\t" "connect to WPA-Network SSID, if pass isn't specified, read from stdin\n"
"tunnel\t" "connects stdout/stdin to the ev3 VM\n"

Definition at line 67 of file main.c.

char* usb_id

Definition at line 125 of file main.c.