20 #define CHUNK_SIZE 1000 // EV3's HID driver doesn't do packets > 1024B
26 int dl(
const char *path, FILE *fp)
29 size_t path_sz = strlen(path) + 1;
39 errmsg =
"Unable to write BEGIN_UPLOAD.";
43 void *file_chunk = malloc(file_chunksz);
50 errmsg =
"Unable to read BEGIN_UPLOAD";
57 fputs(
"Operation failed.\nlast_reply=", stderr);
61 errmsg =
"`BEGIN_UPLOAD` was denied.";
65 fwrite(burep->
bytes, read_so_far, 1, fp);
74 while(read_so_far < total)
79 errmsg =
"Unable to write CONTINUE_UPLOAD";
86 errmsg =
"Unable to read CONTINUE_UPLOAD_REPLY";
92 fputs(
"Operation failed.\nlast_reply=", stderr);
95 errmsg =
"`CONTINUE_UPLOAD` was denied.";
99 fwrite(curep->
bytes, read_this_time, 1, fp);
101 read_so_far += read_this_time;
105 errmsg =
"`BEGIN_UPLOAD` was successful.";
const CONTINUE_UPLOAD CONTINUE_UPLOAD_INIT
EV3_REPLY_FIELDS u8 fileHandle
EV3_COMMAND_FIELDS u16 maxBytes
Error enumerations and decriptions.
int dl(const char *path, FILE *fp)
download remote source rem to local file loc
#define print_bytes(buf, len)
#define packet_alloc(type, extra)
continue download from ev3
EV3_REPLY_FIELDS u32 fileSize
EXTERN int(* ev3_read_timeout)(void *, u8 *, size_t, int milliseconds)
#define CHUNK_SIZE
Transmission is done in units smaller or equal to CHUNK_SIZE.
continue download from ev3 reply
EV3_COMMAND_FIELDS u8 fileHandle
packed structs for the packets.
EXTERN const char * errmsg
global variable for last error message
contains declarations for ev3 commands
EXTERN int(* ev3_write)(void *, const u8 *, size_t)