comparison gpf/INC/tdc_msg.h @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul : TDC
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose :
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifdef TDC_H
22 #error "TDC.H already included, TDC.H must come after all primitives and messages"
23 #endif
24
25 #ifndef TDC_MSG_H
26 #define TDC_MSG_H
27
28 #if DOT_COMPLETE_DEFINES
29
30 //----------------------------------------------------------------------------
31 // macros to repeat stuff that is similar in many interface classes
32 //----------------------------------------------------------------------------
33
34 #define M_TDC_INTERFACE_PRIM_ADDITIONAL(SHORT_NAME)
35
36 #define M_TDC_INTERFACE_PSTRUCT_ADDITIONAL(SHORT_NAME)
37
38 #define M_TDC_INTERFACE_PUNION_ADDITIONAL(SHORT_NAME)
39
40 #define M_TDC_INTERFACE_SDU_ADDITIONAL(SHORT_NAME)
41
42 #define M_TDC_INTERFACE_PENUM_ADDITIONAL(SHORT_NAME)
43
44 #define M_TDC_INTERFACE_PINT_ADDITIONAL(INT_NAME, SHORT_NAME)
45
46 //-----
47
48 #define M_TDC_INTERFACE_MSG_ADDITIONAL(SHORT_NAME)
49
50 #define M_TDC_INTERFACE_MSTRUCT_ADDITIONAL(SHORT_NAME)
51
52 #define M_TDC_INTERFACE_MUNION_ADDITIONAL(SHORT_NAME)
53
54 #define M_TDC_INTERFACE_MENUM_ADDITIONAL(SHORT_NAME)
55
56 #define M_TDC_INTERFACE_MINT_ADDITIONAL(INT_NAME, SHORT_NAME)
57
58 //-----
59
60 #define M_TDC_INTERFACE_INT_ADDITIONAL(SHORT_NAME)
61
62 #define M_TDC_INTERFACE_XXX_PRIMITIVE_UNION_ADDITIONAL(SAP)
63
64 #define M_TDC_INTERFACE_XXX_MESSAGE_UNION_ADDITIONAL(MSG)
65
66 #define M_TDC_CREATE_DEFAULT_PRIMITIVE_INTERFACE_CLASS(SAP)
67
68 #define M_TDC_INTERFACE_PRIMITIVE_ADDITIONAL()
69
70 #define M_TDC_INTERFACE_PRIMITIVE_ELEMENT_ADDITIONAL(SAP)
71
72 #define M_TDC_CREATE_DEFAULT_MESSAGE_INTERFACE_CLASS(MSG)
73
74 #define M_TDC_INTERFACE_MESSAGE_ADDITIONAL()
75
76 #define M_TDC_INTERFACE_MESSAGE_ELEMENT_ADDITIONAL(MSG)
77
78 #else
79 #endif
80
81 #include "tdc_base.h"
82
83 #ifndef TDC_DESCRIPTOR
84 #include "message.h"
85 #include "primitive.h"
86 #else
87 #include "message_dsc.h"
88 #include "primitive_dsc.h"
89 #endif
90
91 struct T_TDC_INTERFACE_U8;
92
93 //TODO: eliminate need for these types used by M_RR (this is a bug work around)
94 typedef T_TDC_HANDLE_U8 T_TDC_HANDLE_AVG_W;
95 typedef T_TDC_HANDLE_U8 T_TDC_HANDLE_AVG_T;
96 typedef T_TDC_INTERFACE_U8 T_TDC_INTERFACE_AVG_W;
97 typedef T_TDC_INTERFACE_U8 T_TDC_INTERFACE_AVG_T;
98 //TODO: eliminate need for these types used by M_GRR (this is a bug work around)
99 typedef T_TDC_HANDLE_U8 T_TDC_HANDLE_RESEL;
100 typedef T_TDC_INTERFACE_U8 T_TDC_INTERFACE_RESEL;
101
102 typedef struct T_TDC_HANDLE_TEST_var4 T_TDC_HANDLE_TEST_var4T;
103 typedef struct T_TDC_HANDLE_TEST_enum4 T_TDC_HANDLE_TEST_enum4T;
104
105 M_TDC_FORWARD_SDU (sdu)
106 struct T_TDC_DESCRIPTOR_sdu;
107 struct T_TDC_HANDLE_sdu;
108 struct T_TDC_INTERFACE_sdu;
109 struct T_sdu;
110 typedef T_TDC_HANDLE_sdu T_TDC_HANDLE_SDU;
111 typedef T_TDC_DESCRIPTOR_sdu T_TDC_DESCRIPTOR_SDU;
112 typedef T_TDC_INTERFACE_sdu T_TDC_INTERFACE_SDU;
113 typedef T_sdu T_TDC_INSTANCE_SDU;
114
115
116
117 ///\todo make some sencible stuff here
118 struct T_TDC_HANDLE_desc_list
119 {
120 int dummy_to_keep_doxygen_happy;
121 };
122
123 ///\todo make some sencible stuff here
124 struct T_TDC_HANDLE_desc
125 {
126 int dummy_to_keep_doxygen_happy;
127 };
128
129 ///\todo make some sencible stuff here
130 struct T_TDC_INTERFACE_desc_list
131 {
132 int dummy_to_keep_doxygen_happy;
133 };
134
135 ///\todo make some sencible stuff here
136 struct T_TDC_INTERFACE_desc
137 {
138 int dummy_to_keep_doxygen_happy;
139 };
140
141
142
143 #ifdef TDC_DESCRIPTOR
144
145 /*M_TDC_FORWARD_PSTRUCT(raw)
146 M_TDC_FORWARD_PSTRUCT(aim)
147 M_TDC_FORWARD_PSTRUCT(sdu)*/
148
149 struct T_TDC_DESCRIPTOR_aim:T_TDC_DESCRIPTOR_PSTRUCT_BASE
150 {
151 M_TDC_DESCRIPTOR_PSTRUCT_ADDITIONAL (aim)
152 T_TDC_HANDLE_U8 ti;
153 T_TDC_HANDLE_U8 tie;
154 T_TDC_HANDLE_U8 nsd;
155 T_TDC_HANDLE_MESSAGE_UNION entity;
156 };
157
158 struct T_TDC_DESCRIPTOR_sdu:T_TDC_DESCRIPTOR_SDU_BASE
159 {
160 M_TDC_DESCRIPTOR_SDU_ADDITIONAL (sdu)
161 T_TDC_HANDLE_raw raw; //manual sdu
162 T_TDC_HANDLE_aim aim; //coded sdu
163 };
164
165 #endif
166
167 #if !defined TDC_DESCRIPTOR || defined TDC_PRECOMPILE
168
169 struct T_aim:T_TDC_INSTANCE_PSTRUCT_BASE
170 {
171 M_TDC_INSTANCE_PSTRUCT_ADDITIONAL (aim,aim)
172 T_TDC_INTERFACE_aim* operator-> ();
173 };
174 struct T_TDC_INTERFACE_aim:T_TDC_INTERFACE_PSTRUCT_BASE
175 {
176 M_TDC_INTERFACE_PSTRUCT_ADDITIONAL (aim,aim)
177 T_TDC_INTERFACE_U8 ti;
178 T_TDC_INTERFACE_U8 tie;
179 T_TDC_INTERFACE_U8 nsd;
180 T_TDC_INTERFACE_MESSAGE_UNION entity;
181 #ifdef TDC_TYPE_NAME_COMPLETE
182 struct { char T_aim, ___ti___tie___nsd___entiy; } _type_name ();
183 #endif
184 };
185
186 struct T_sdu:T_TDC_INSTANCE_SDU_BASE
187 {
188 M_TDC_INSTANCE_SDU_ADDITIONAL (sdu)
189 T_sdu(const T_MESSAGE_UNION& msg);
190 T_sdu(const T_TDC_INSTANCE_MSG_BASE& msg);
191 T_TDC_INTERFACE_sdu* operator-> ();
192 };
193 struct T_TDC_INTERFACE_sdu:T_TDC_INTERFACE_SDU_BASE
194 {
195 M_TDC_INTERFACE_PSTRUCT_ADDITIONAL (sdu,sdu)
196 T_TDC_INTERFACE_raw raw; //manual sdu
197 T_TDC_INTERFACE_aim aim; //coded sdu
198 #ifdef TDC_TYPE_NAME_COMPLETE
199 struct { char T_sdu, ___raw___aim; } _type_name ();
200 #endif
201 };
202 inline T_sdu::T_sdu(const T_MESSAGE_UNION& msg)
203 {
204 construct();
205 (*this)->aim.entity=msg;
206 }
207 inline T_sdu::T_sdu(const T_TDC_INSTANCE_MSG_BASE& msg)
208 {
209 construct();
210 (*this)->aim.entity=msg;
211 }
212
213
214 #endif //!defined TDC_DESCRIPTOR || defined TDC_PRECOMPILE
215
216 //============================================================================
217 template <class T>
218 T_sdu tds_array_to_sdu(const T& U8array)
219 //This function is a temporary solution to help the convertion from TDS U8 arrays to TDC SDU's.
220 {
221 T_sdu sdu;
222 sdu->raw.l_buf = U8array[0] + U8array[1] * 256;
223 sdu->raw.o_buf = U8array[2] + U8array[3] * 256;
224 if (sizeof(U8array)>4)
225 {
226 for (int i = 4; i < sizeof(U8array);i++)
227 {
228 sdu->raw.buf[i-4] = U8array[i];
229 }
230 }
231 else
232 {
233 sdu->raw.buf = T_ARRAY<U8>();
234 }
235 return sdu;
236 }
237 //============================================================================
238 template <class T>
239 T_sdu BIN(const T& U8array)
240 {
241 T_sdu sdu;
242 int i=0,bit=0,l_buf=0;
243 U8 temp=0;
244
245 while(U8array[i] != '\0')
246 {
247 if(U8array[i] == 0x20) //(0x20 is space)
248 {
249 if(bit != 0)
250 tdc_user_error("BIN(): There is not 8 bits between spaces!");
251 }
252 else
253 {
254 switch(U8array[i])
255 {
256 case 0x31: //(0x31 ascii code for 1)
257 temp += 1<<(7-bit);
258 break;
259
260 case 0x30: //(0x30 ascii code for 0)
261 break;
262
263 default:
264 tdc_user_error("BIN(): string character neither '0' or '1': %c",U8array[i]);
265 break;
266 }
267 bit ++;
268 if(bit == 8)
269 {
270 sdu->raw.buf[l_buf/8] = temp;
271 temp = 0;
272 bit=0;
273 }
274 l_buf++;
275 }
276 i++;
277 }
278 if(bit != 0) //if the number of bits is not a multiplum of 8 the last few bits will be assigned here
279 {
280 sdu->raw.buf[l_buf/8] = temp;
281 }
282
283 sdu->raw.l_buf=l_buf;
284 sdu->raw.o_buf=0;
285 return sdu;
286 }
287
288 template <class T>
289 T_sdu HEX(const T& U8array)
290 {
291 T_sdu sdu;
292 int i = 0, nibble = 0, l_buf = 0;
293 U8 temp = 0;
294
295 while(U8array[i] != '\0')
296 {
297 if(U8array[i] == 0x20) //(0x20 is space)
298 {
299 if(nibble != 0)
300 tdc_user_error("HEX(): There is not 2 nibbles between spaces!");
301 }
302 else
303 {
304 if(('0' <= U8array[i]) && (U8array[i] <= '9'))
305 {
306 temp += (U8array[i] - 0x30) << (4*(1-nibble));
307 }
308 else if(('A' <= U8array[i]) && (U8array[i] <= 'F'))
309 {
310 temp += (U8array[i] - 0x37) << (4*(1-nibble));
311 }
312 else if(('a' <= U8array[i]) && (U8array[i] <= 'f'))
313 {
314 temp += (U8array[i] - 0x57) << (4*(1-nibble));
315 }
316 else
317 {
318 tdc_user_error("HEX(): String character not a HEX number: %c",U8array[i]);
319 }
320 nibble ++;
321 if(nibble == 2)
322 {
323 sdu->raw.buf[l_buf/8] = temp;
324 temp = 0;
325 nibble = 0;
326 }
327 l_buf += 4;
328 }
329 i++;
330 }
331
332 if(nibble != 0) //checks whether the number of nibbles are odd. IF THIS SHOULD BE MADE LEGAL
333 { //remove the '//' in front of the line above and comment out the error function call!
334 tdc_user_error("HEX(): Odd number of nibbles (hex numbers)");
335 //sdu->raw.buf[l_buf/8]=temp;
336 }
337 sdu->raw.l_buf = l_buf;
338 sdu->raw.o_buf = 0;
339 return sdu;
340 }
341
342 template <class T>
343 T_sdu CHR(const T& U8array)
344 {
345 T_sdu sdu;
346 int i=0;
347 while(U8array[i] != '\0')
348 {
349 sdu->raw.buf[i]= (U8)U8array[i];
350 i++;
351 }
352 sdu->raw.l_buf=8*i;
353 sdu->raw.o_buf=0;
354 return sdu;
355 }
356
357 #endif //TDC_MSG_H