ev3duder  0.3.0
EV3 Downloader/Uploader
packets.h File Reference

packed structs for the packets. More...

#include "defs.h"

Go to the source code of this file.

Data Structures

struct  SYSTEM_CMD
 base packet for SYSTEM COMMANDS More...
 
struct  SYSTEM_REPLY
 base packet for SYSTEM REPLIES More...
 
struct  BEGIN_DOWNLOAD
 upload to EV3 More...
 
struct  BEGIN_DOWNLOAD_REPLY
 Th ev3's reply. More...
 
struct  CONTINUE_DOWNLOAD
 send file chunk wise More...
 
struct  BEGIN_UPLOAD
 download from EV3 More...
 
struct  BEGIN_UPLOAD_REPLY
 download from EV3 reply More...
 
struct  CONTINUE_UPLOAD
 continue download from ev3 More...
 
struct  CONTINUE_UPLOAD_REPLY
 continue download from ev3 reply More...
 
struct  LIST_FILES
 List files on EV3. More...
 
struct  LIST_FILES_REPLY
 Directory contents on EV3. More...
 
struct  CONTINUE_LIST_FILES
 
struct  CONTINUE_LIST_FILES_REPLY
 
struct  CREATE_DIR
 create directory More...
 
struct  DELETE_FILE
 delete file More...
 
struct  BLUETOOTHPIN_REPLY
 untested and unused More...
 
struct  VM_CMD
 base packet More...
 
struct  VM_REPLY
 base reply packet More...
 

Macros

#define HID_LAYER   u8 hidLayer;
 Is always zero. Also called HID report ID. More...
 
#define EV3_PACKET_FIELDS
 
#define EV3_COMMAND_FIELDS
 
#define EV3_REPLY_FIELDS
 
#define PREFIX_SIZE   3
 
#define EV3_VM_COMMAND_FIELDS
 VM stuff. More...
 
#define packet_alloc(type, extra)
 

Typedefs

typedef BEGIN_DOWNLOAD_REPLY CONTINUE_DOWNLOAD_REPLY
 
typedef LIST_FILES BEGIN_GETFILE
 
typedef SYSTEM_REPLY CREATE_DIR_REPLY
 
typedef SYSTEM_REPLY DELETE_FILE_REPLY
 
typedef SYSTEM_CMD BLUETOOTHPIN
 set bluetooth pin, untested More...
 
typedef SYSTEM_CMD ENTERFWUPDATE
 Force brick into Firmware update mode, untested and unused. More...
 
typedef VM_CMD EXECUTE_FILE
 

Variables

const BEGIN_DOWNLOAD BEGIN_DOWNLOAD_INIT
 
const CONTINUE_DOWNLOAD CONTINUE_DOWNLOAD_INIT
 
const CONTINUE_DOWNLOAD_REPLY CONTINUE_DOWNLOAD_REPLY_SUCCESS
 
const CONTINUE_UPLOAD CONTINUE_UPLOAD_INIT
 
const BEGIN_UPLOAD BEGIN_UPLOAD_INIT
 
const LIST_FILES LIST_FILES_INIT
 
const BEGIN_GETFILE BEGIN_GETFILE_INIT
 
const CONTINUE_LIST_FILES CONTINUE_LIST_FILES_INIT
 
const CREATE_DIR CREATE_DIR_INIT
 
const DELETE_FILE DELETE_FILE_INIT
 
const BLUETOOTHPIN BLUETOOTHPIN_INIT
 
const ENTERFWUPDATE ENTERFWUPDATE_INIT
 
const EXECUTE_FILE EXECUTE_FILE_INIT
 
const VM_REPLY EXECUTE_FILE_REPLY_SUCCESS
 

Detailed Description

packed structs for the packets.

Author
Ahmad Fatoum
Bug:
A more standard approach like libpack might be worthwhile.

Definition in file packets.h.

Macro Definition Documentation

#define EV3_COMMAND_FIELDS
Value:
u8 replyType;\
u8 cmd;
uint8_t u8
Definition: defs.h:9

replyType defines whether client demands answer. (Yes he always does) cmd packet id, is set by specifing correct data type in packet_alloc(). Manual handling is not intended, therefore in #define

Definition at line 32 of file packets.h.

#define EV3_PACKET_FIELDS
Value:
u16 packetLen;\
u16 msgCount;
uint16_t u16
Definition: defs.h:10

packetLen isn't supposed to be handled outside of packet_alloc(), therefore abstracted into a #define msgCount might (?) be used for checking dropped or out-of-order packets. Which would be pointless as TCP and RFCOMM both guarantee reliability anyway

Definition at line 23 of file packets.h.

#define EV3_REPLY_FIELDS
Value:
u8 type; \
u8 cmd; \
u8 ret;
uint8_t u8
Definition: defs.h:9

additionally ret describes the return value for last action

See also
error.h for how to interpret these codes

Definition at line 42 of file packets.h.

#define EV3_VM_COMMAND_FIELDS
Value:
u8 replyType; \
u16 alloc;
uint16_t u16
Definition: defs.h:10
uint8_t u8
Definition: defs.h:9

VM stuff.

Definition at line 278 of file packets.h.

#define HID_LAYER   u8 hidLayer;

Is always zero. Also called HID report ID.

Definition at line 15 of file packets.h.

#define packet_alloc (   type,
  extra 
)
Value:
({ \
void *ptr = NULL; \
if ((sizeof(type) + extra < (u16)-1) \
&& (ptr = malloc(sizeof(type) + extra))) { \
memcpy(ptr, &type##_INIT, sizeof(type)); \
((SYSTEM_CMD *)ptr)->packetLen = (u16)(sizeof(type) + extra - PREFIX_SIZE); \
} \
ptr;})
uint16_t u16
Definition: defs.h:10
base packet for SYSTEM COMMANDS
Definition: packets.h:64
#define PREFIX_SIZE
Definition: packets.h:54

for variably sized packets. Allocates space, initializes and adjusts packetLen field

Note
employs the compound statement expression GNU extension

Definition at line 328 of file packets.h.

#define PREFIX_SIZE   3

bytes not covered by packetLen (3B = 1B hidLayer + 2B packetLen itself)

Bug:
hidLayer shouldn't be maintained here as it's non-sense to demand bluetooth to account for it Maybe wrap HIDAPI with a wrapper that prefixes zero automatically, instead of having bt_write() omit the first byte

Definition at line 54 of file packets.h.

Typedef Documentation

Definition at line 176 of file packets.h.

set bluetooth pin, untested

Definition at line 252 of file packets.h.

Definition at line 112 of file packets.h.

Definition at line 238 of file packets.h.

Definition at line 249 of file packets.h.

Force brick into Firmware update mode, untested and unused.

Definition at line 273 of file packets.h.

Definition at line 292 of file packets.h.

Variable Documentation

const BEGIN_DOWNLOAD BEGIN_DOWNLOAD_INIT

Definition at line 10 of file packets.c.

const BEGIN_GETFILE BEGIN_GETFILE_INIT

Definition at line 31 of file packets.c.

const BEGIN_UPLOAD BEGIN_UPLOAD_INIT

Definition at line 19 of file packets.c.

const BLUETOOTHPIN BLUETOOTHPIN_INIT

Definition at line 40 of file packets.c.

const CONTINUE_DOWNLOAD CONTINUE_DOWNLOAD_INIT

Definition at line 13 of file packets.c.

const CONTINUE_DOWNLOAD_REPLY CONTINUE_DOWNLOAD_REPLY_SUCCESS

Definition at line 16 of file packets.c.

const CONTINUE_LIST_FILES CONTINUE_LIST_FILES_INIT

Definition at line 28 of file packets.c.

const CONTINUE_UPLOAD CONTINUE_UPLOAD_INIT

Definition at line 22 of file packets.c.

const CREATE_DIR CREATE_DIR_INIT

Definition at line 34 of file packets.c.

const DELETE_FILE DELETE_FILE_INIT

Definition at line 37 of file packets.c.

const ENTERFWUPDATE ENTERFWUPDATE_INIT

Definition at line 43 of file packets.c.

const EXECUTE_FILE EXECUTE_FILE_INIT

Definition at line 46 of file packets.c.

const VM_REPLY EXECUTE_FILE_REPLY_SUCCESS

Definition at line 49 of file packets.c.

const LIST_FILES LIST_FILES_INIT

Definition at line 25 of file packets.c.