dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
uavtalk_priv.h
Go to the documentation of this file.
1 
15 /*
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24  * for more details.
25  *
26  * You should have received a copy of the GNU General Public License along
27  * with this program; if not, see <http://www.gnu.org/licenses/>
28  */
29 
30 #ifndef UAVTALK_PRIV_H
31 #define UAVTALK_PRIV_H
32 
33 #include "uavobjectsinit.h"
34 #include "pios_semaphore.h"
35 #include "pios_mutex.h"
36 
37 // Private types and constants
38 
40 typedef struct {
41  uint8_t sync;
42  uint8_t type;
43  uint16_t size;
44  uint32_t objId;
46 #define UAVTALK_MIN_HEADER_LENGTH sizeof(uavtalk_min_header)
47 
49 typedef struct {
50  uint8_t sync;
51  uint8_t type;
52  uint16_t size;
53  uint32_t objId;
54  uint16_t instId;
56 #define UAVTALK_MAX_HEADER_LENGTH sizeof(uavtalk_max_header)
57 
58 struct filereq_data {
59  uint32_t offset;
60  uint16_t flags;
61 } __attribute__((packed));
62 
63 struct fileresp_data {
64  uint32_t offset;
65  uint8_t flags;
66 } __attribute__((packed));
67 
68 typedef uint8_t uavtalk_checksum;
69 #define UAVTALK_CHECKSUM_LENGTH sizeof(uavtalk_checksum)
70 #define UAVTALK_MAX_PAYLOAD_LENGTH (UAVOBJECTS_LARGEST + 1)
71 #define UAVTALK_MIN_PACKET_LENGTH UAVTALK_MAX_HEADER_LENGTH + UAVTALK_CHECKSUM_LENGTH
72 #define UAVTALK_MAX_PACKET_LENGTH UAVTALK_MIN_PACKET_LENGTH + UAVTALK_MAX_PAYLOAD_LENGTH
73 
75 typedef struct {
77  uint8_t type;
78  uint16_t packet_size;
79  uint32_t objId;
80  uint16_t instId;
81  uint32_t length;
82  uint8_t instanceLength;
83  uint8_t cs;
84  int32_t rxCount;
86  uint16_t rxPacketLength;
88 
90 typedef struct {
91  uint8_t canari;
95  uint8_t *rxBuffer;
96  uint32_t txSize;
97  uint8_t *txBuffer;
98 
103  void *cbCtx;
105 
106 #define UAVTALK_CANARI 0xCA
107 #define UAVTALK_WAITFOREVER -1
108 #define UAVTALK_NOWAIT 0
109 #define UAVTALK_SYNC_VAL 0x3C
110 #define UAVTALK_TYPE_MASK 0x70
111 #define UAVTALK_TYPE_VER 0x20
112 #define UAVTALK_TIMESTAMPED 0x80
113 #define UAVTALK_TYPE_OBJ (UAVTALK_TYPE_VER | 0x00)
114 #define UAVTALK_TYPE_OBJ_REQ (UAVTALK_TYPE_VER | 0x01)
115 #define UAVTALK_TYPE_OBJ_ACK (UAVTALK_TYPE_VER | 0x02)
116 #define UAVTALK_TYPE_ACK (UAVTALK_TYPE_VER | 0x03)
117 #define UAVTALK_TYPE_NACK (UAVTALK_TYPE_VER | 0x04)
118 #define UAVTALK_TYPE_FILEREQ (UAVTALK_TYPE_VER | 0x08)
119 #define UAVTALK_TYPE_FILEDATA (UAVTALK_TYPE_VER | 0x09)
120 #define UAVTALK_TYPE_OBJ_TS (UAVTALK_TIMESTAMPED | UAVTALK_TYPE_OBJ)
121 
122 #define UAVTALK_FILEDATA_EOF 0x01
123 #define UAVTALK_FILEDATA_LAST 0x02
124 
125 //macros
126 #define CHECKCONHANDLE(handle,variable,failcommand) \
127  variable = (UAVTalkConnectionData*) handle; \
128  if (variable == NULL || variable->canari != UAVTALK_CANARI) { \
129  failcommand; \
130  }
131 
132 #endif /* UAVTALK_PRIV_H */
133 
int32_t(* UAVTalkOutputCb)(void *ctx, uint8_t *data, int32_t length)
Definition: uavtalk.h:34
void(* UAVTalkAckCb)(void *ctx, uint32_t obj_id, uint16_t inst_id)
Definition: uavtalk.h:35
UAVTalkRxState state
Definition: uavtalk_priv.h:85
UAVTalkInputProcessor iproc
Definition: uavtalk_priv.h:94
void(* UAVTalkReqCb)(void *ctx, uint32_t obj_id, uint16_t inst_id)
Definition: uavtalk.h:36
uint8_t uavtalk_checksum
Definition: uavtalk_priv.h:68
uint32_t offset
Definition: uavtalk_priv.h:59
Full UAVTalk header with an instance field.
Definition: uavtalk_priv.h:49
Minimal UAVTalk header without an instance field.
Definition: uavtalk_priv.h:40
int32_t(* UAVTalkFileCb)(void *ctx, uint8_t *buf, uint32_t file_id, uint32_t offset, uint32_t len)
Definition: uavtalk.h:37
UAVTalkOutputCb outCb
Definition: uavtalk_priv.h:99
struct pios_recursive_mutex * lock
Definition: uavtalk_priv.h:92
uint16_t flags
Definition: uavtalk_priv.h:60
State information for the UAVTalk parser.
Definition: uavtalk_priv.h:75
uint32_t offset
Definition: uavtalk_priv.h:64
Tracking statistics for a UAVTalk connection.
Definition: uavtalk.h:41
Information for the physical link.
Definition: uavtalk_priv.h:90
uint8_t type
UAVTalkFileCb fileCb
Definition: uavtalk_priv.h:102
uint8_t flags
Definition: uavtalk_priv.h:65
UAVTalkRxState
Definition: uavtalk.h:55
UAVTalkStats stats
Definition: uavtalk_priv.h:93
typedef __attribute__
Definition: serial_4way.h:43