20 #define CHUNK_SIZE 1000 // The EV3 doesn't do packets > 1024B
29 int up(FILE *fp,
const char *dst)
33 fseek(fp, 0, SEEK_END);
34 long fsize = ftell(fp);
35 fseek(fp, 0, SEEK_SET);
37 if ((
unsigned long)fsize > (
u32)-1)
45 size_t dst_len = strlen(dst) + 1;
53 errmsg =
"Unable to write BEGIN_DOWNLOAD.";
61 errmsg =
"Unable to read BEGIN_DOWNLOAD";
68 errmsg =
"BEGIN_DOWNLOAD was denied.";
73 for (
size_t i = 0; i < chunks; ++i)
81 errmsg =
"Unable to write CONTINUE_DOWNLOAD.";
87 errmsg =
"Unable to read CONTINUE_DOWNLOAD";
92 fread(cd->
fileChunk, 1, final_chunk_sz, fp);
96 errmsg =
"Unable to write CONTINUE_DOWNLOAD.";
102 errmsg =
"Unable to read CONTINUE_DOWNLOAD";
109 fputs(
"Transfer failed.\nlast_reply=", stderr);
113 errmsg =
"CONTINUE_DOWNLOAD was denied.";
117 errmsg =
"`upload` was successful.";
EV3_REPLY_FIELDS u8 fileHandle
EV3_COMMAND_FIELDS u8 fileHandle
Error enumerations and decriptions.
#define print_bytes(buf, len)
#define packet_alloc(type, extra)
EXTERN int(* ev3_read_timeout)(void *, u8 *, size_t, int milliseconds)
packed structs for the packets.
int up(FILE *fp, const char *dst)
Uploads file to the ev3. path is always relative to /home/root/lms2012/prjs/sys/
EV3_COMMAND_FIELDS u32 fileSize
EXTERN const char * errmsg
global variable for last error message
contains declarations for ev3 commands
EXTERN int(* ev3_write)(void *, const u8 *, size_t)