FreeCalypso > hg > tcs211-l1-reconst
comparison g23m/condat/ms/src/aci/ati_src_tst.c @ 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 : GSM-PS (6147) | |
4 | Modul : ATI_SRC_TST | |
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 : this source is used for W32 tests | |
18 +----------------------------------------------------------------------------- | |
19 */ | |
20 | |
21 #ifdef DTI | |
22 | |
23 #ifndef ATI_SRC_TST_C | |
24 #define ATI_SRC_TST_C | |
25 #endif | |
26 | |
27 #include "aci_all.h" | |
28 /*==== INCLUDES ===================================================*/ | |
29 #include "line_edit.h" | |
30 #include "aci_cmh.h" | |
31 #include "ati_cmd.h" | |
32 #include "aci_cmd.h" | |
33 #include "dti.h" /* functionality of the dti library */ | |
34 | |
35 #include "aci_lst.h" | |
36 #include "dti_conn_mng.h" | |
37 #ifdef UART | |
38 #include "psa_uart.h" | |
39 #include "cmh_uart.h" | |
40 #endif | |
41 #ifdef FF_PSI | |
42 #include "psa_psi.h" | |
43 #include "cmh_psi.h" | |
44 #endif /*FF_PSI*/ | |
45 #include "aci_io.h" | |
46 #include "aci_mem.h" | |
47 #include "aci.h" | |
48 #include "ati_io.h" | |
49 | |
50 #define ATI_SRC_TST_GLOBALS | |
51 #include "ati_src_tst.h" | |
52 | |
53 #include "sap_dti.h" | |
54 #include "ati_int.h" | |
55 #ifdef UART | |
56 #include "ati_src_uart.h" | |
57 #endif | |
58 #ifdef FF_PSI | |
59 #include "ati_src_psi.h" | |
60 #endif /*FF_PSI*/ | |
61 #ifdef FF_ATI_BAT | |
62 #include "ati_bat.h" | |
63 #endif /* FF_ATI_BAT */ | |
64 | |
65 /*==== CONSTANTS ==================================================*/ | |
66 | |
67 /*==== TYPES ======================================================*/ | |
68 | |
69 /*==== EXPORT =====================================================*/ | |
70 | |
71 /*==== VARIABLES ==================================================*/ | |
72 | |
73 /*==== FUNCTIONS ==================================================*/ | |
74 | |
75 EXTERN void uart_src_test_sendString (UBYTE *string, USHORT string_len, | |
76 T_ACI_DTI_PRC *src_infos, | |
77 T_ATI_OUTPUT_TYPE output_type); | |
78 | |
79 | |
80 /*=================================================================*/ | |
81 | |
82 /* | |
83 +-------------------------------------------------------------------+ | |
84 | PROJECT : GSM-PS (6147) MODULE : ati_src_tst | | |
85 | ROUTINE : ati_src_tst_result_cb | | |
86 +-------------------------------------------------------------------+ | |
87 | |
88 PURPOSE : | |
89 */ | |
90 GLOBAL void ati_src_tst_result_cb (UBYTE src_id, | |
91 T_ATI_OUTPUT_TYPE output_type, | |
92 UBYTE *output, | |
93 USHORT output_len) | |
94 { | |
95 #ifdef UART | |
96 T_ACI_DTI_PRC *src_infos = NULL; | |
97 #endif | |
98 #ifdef FF_PSI | |
99 T_ACI_DTI_PRC_PSI *src_infos_psi = NULL; | |
100 #endif /*FF_PSI*/ | |
101 if( output_len EQ 0 ) | |
102 { | |
103 /* if length is 0, then do not send (happens if some | |
104 formatting characters, e.g CR or LF have been sent: they are irrelevant | |
105 for this source...) */ | |
106 return; | |
107 } | |
108 | |
109 #ifdef RMV_01_04_03 | |
110 #ifdef FF_TWO_UART_PORTS | |
111 /* disable output to UART on data channel */ | |
112 if (src_id EQ UART_DATA_CHANNEL) | |
113 { | |
114 return; | |
115 } | |
116 #endif | |
117 #endif | |
118 | |
119 #ifdef UART | |
120 src_infos = find_element (uart_src_params, (UBYTE)src_id, cmhUARTtest_srcId); | |
121 #endif | |
122 | |
123 #ifdef FF_PSI | |
124 src_infos_psi = find_element (psi_src_params, src_id, cmhPSItest_srcId); | |
125 #endif /*FF_PSI*/ | |
126 #if 0 | |
127 if (src_infos EQ NULL) | |
128 { | |
129 TRACE_EVENT_P1("[ERR] uart_src_result_cb: src_id=%d not found", src_id) ; | |
130 return; | |
131 } | |
132 #endif | |
133 | |
134 if (IS_ECHO_OUTPUT (output_type) AND !IS_CONFIRM_OUTPUT (output_type)) | |
135 { | |
136 return; | |
137 } | |
138 else | |
139 { | |
140 if( | |
141 #ifdef UART | |
142 (src_infos EQ NULL) | |
143 #else | |
144 TRUE | |
145 #endif | |
146 AND | |
147 #ifdef FF_PSI | |
148 (src_infos_psi EQ NULL) | |
149 #else | |
150 TRUE | |
151 #endif | |
152 ) | |
153 { | |
154 PALLOC (aci_cmd_ind, ACI_CMD_IND); | |
155 | |
156 TRACE_FUNCTION ("ati_src_tst_result_cb ()"); | |
157 | |
158 /* aci_cmd_ind->cmd_len = output_len; */ | |
159 /* | |
160 * SKA 2002-09-11 to make the TST source V.25 ter compatible, but don't change | |
161 * existing test cases, remove the '\r' which we inserted in aci_aci_cmd_req | |
162 * and reduce the length by one | |
163 */ | |
164 if (*(output+output_len-1) EQ '\r') | |
165 { | |
166 *(output+output_len-1) = '\0'; /* remove the '\r' */ | |
167 --output_len; | |
168 } | |
169 | |
170 aci_cmd_ind->cmd_len = output_len; | |
171 strncpy ((CHAR*)aci_cmd_ind->cmd_seq, output, output_len); | |
172 | |
173 trace_cmd_line ("ATI TST Output", (char *)output, src_id, output_len); | |
174 | |
175 PSENDX (ACI, aci_cmd_ind); | |
176 } | |
177 #ifdef UART | |
178 else if (src_infos NEQ NULL) | |
179 { | |
180 uart_src_test_sendString(output, output_len, src_infos, output_type); | |
181 } | |
182 #endif | |
183 #ifdef FF_PSI | |
184 else /*PSI src*/ | |
185 { | |
186 psi_src_test_sendString(output, output_len, src_infos_psi, output_type); | |
187 } | |
188 #endif /*FF_PSI*/ | |
189 } | |
190 } | |
191 | |
192 /* | |
193 +-------------------------------------------------------------------+ | |
194 | PROJECT : GSM-PS (6147) MODULE : ati_src_tst | | |
195 | ROUTINE : ati_src_tst_line_state_cb | | |
196 +-------------------------------------------------------------------+ | |
197 | |
198 PURPOSE : register the test source for W32 tests at the ATI | |
199 */ | |
200 GLOBAL void ati_src_tst_line_state_cb (UBYTE src_id, | |
201 T_ATI_LINE_STATE_TYPE line_state_type, | |
202 ULONG line_state_param) | |
203 { | |
204 TRACE_FUNCTION ("ati_src_tst_line_state_cb ()"); | |
205 | |
206 switch (line_state_type) | |
207 { | |
208 case ATI_LINE_STATE_OUTPUT_TYPE: | |
209 TRACE_EVENT_P1 ("[DBG] ati_src_tst_line_state_cb (): ATI_LINE_STATE_OUTPUT_TYPE = %d", line_state_param); | |
210 break; | |
211 | |
212 case ATI_LINE_STATE_DCD: | |
213 TRACE_EVENT_P1 ("[DBG] ati_src_tst_line_state_cb (): ATI_LINE_STATE_DCD = %d", line_state_param); | |
214 break; | |
215 | |
216 case ATI_LINE_STATE_RNG: /* TODO */ | |
217 { | |
218 T_IO_RING_PARAMS rng_params; | |
219 | |
220 memcpy (&rng_params, (T_IO_RING_PARAMS*)line_state_param, | |
221 sizeof(T_IO_RING_PARAMS)); | |
222 | |
223 TRACE_EVENT_P1 ("[DBG] ati_src_tst_line_state_cb (): ATI_LINE_STATE_RNG = %d", rng_params.ring_stat); | |
224 | |
225 break; | |
226 } | |
227 | |
228 default: | |
229 TRACE_EVENT_P1 ("[WRN] ati_src_tst_line_state_cb (): UNKNOWN line_state_type = %d", line_state_type); | |
230 break; | |
231 } | |
232 } | |
233 | |
234 | |
235 /* | |
236 +-------------------------------------------------------------------+ | |
237 | PROJECT : GSM-PS (6147) MODULE : ati_src_tst | | |
238 | ROUTINE : ati_src_tst_init | | |
239 +-------------------------------------------------------------------+ | |
240 | |
241 PURPOSE : register the test source for W32 tests at the ATI | |
242 */ | |
243 | |
244 GLOBAL void ati_src_tst_init ( UBYTE cmd_src ) | |
245 { | |
246 int i; | |
247 static BOOL initialzed = FALSE; | |
248 TRACE_FUNCTION ("ati_src_tst_init ()"); | |
249 | |
250 if (initialzed EQ FALSE) | |
251 { | |
252 for (i=0; i<MAX_TST_SRC; i++) | |
253 { | |
254 tst_src_id[i] = 0; | |
255 } | |
256 initialzed = TRUE; | |
257 } | |
258 | |
259 tst_src_id[cmd_src - 1] = ati_init (ATI_SRC_TYPE_TST, | |
260 ati_src_tst_result_cb, | |
261 ati_src_tst_line_state_cb); | |
262 | |
263 TRACE_EVENT_P1 ("ati_src_tst_init: srcId=%d", tst_src_id[cmd_src - 1]); | |
264 #ifndef FF_ATI_BAT | |
265 if (tst_src_id[cmd_src - 1]<CMD_SRC_MAX) | |
266 { | |
267 if (tst_src_id[cmd_src - 1]==CMD_SRC_LCL) | |
268 aci_cmd_src_mode_set(tst_src_id[cmd_src - 1],CMD_MODE_ACI); | |
269 else | |
270 aci_cmd_src_mode_set(tst_src_id[cmd_src - 1],CMD_MODE_ATI); | |
271 } | |
272 #endif | |
273 ati_switch_mode(tst_src_id[cmd_src - 1], ATI_CMD_MODE); | |
274 } | |
275 | |
276 /* | |
277 +-------------------------------------------------------------------+ | |
278 | PROJECT : GSM-PS (6147) MODULE : ati_src_tst | | |
279 | ROUTINE : ati_src_tst_get_src_id | | |
280 +-------------------------------------------------------------------+ | |
281 | |
282 PURPOSE : get the test source for W32 tests at the ATI | |
283 */ | |
284 | |
285 GLOBAL UBYTE ati_src_tst_get_src_id ( UBYTE cmd_src ) | |
286 { | |
287 | |
288 TRACE_FUNCTION ("ati_src_tst_get_src_id ()"); | |
289 | |
290 if ( cmd_src EQ CMD_SRC_UNKNOWN ) | |
291 { | |
292 cmd_src = CMD_SRC_EXT; | |
293 while ( cmd_src < MAX_TST_SRC && tst_src_id[cmd_src - 1] NEQ DTI_MNG_ID_NOTPRESENT ) | |
294 { | |
295 cmd_src++; | |
296 } | |
297 | |
298 if ( cmd_src > MAX_TST_SRC || cmd_src EQ CMD_SRC_UNKNOWN ) | |
299 { | |
300 return DTI_MNG_ID_NOTPRESENT; | |
301 } | |
302 | |
303 ati_src_tst_init( cmd_src ); | |
304 } | |
305 | |
306 return tst_src_id[cmd_src - 1]; | |
307 } | |
308 | |
309 /* | |
310 +-------------------------------------------------------------------+ | |
311 | PROJECT : GSM-PS (6147) MODULE : ati_src_tst | | |
312 | ROUTINE : ati_src_tst_finit | | |
313 +-------------------------------------------------------------------+ | |
314 | |
315 PURPOSE : deregister the test source for W32 tests at the ATI | |
316 */ | |
317 | |
318 GLOBAL void ati_src_tst_finit (void) | |
319 { | |
320 SHORT i = 0; | |
321 | |
322 TRACE_FUNCTION ("ati_src_tst_finit ()"); | |
323 | |
324 for ( i = 0; i < MAX_TST_SRC AND tst_src_id[i] NEQ DTI_MNG_ID_NOTPRESENT; i++) | |
325 { | |
326 ati_finit (tst_src_id[i]); | |
327 tst_src_id[i] = DTI_MNG_ID_NOTPRESENT; | |
328 } | |
329 } | |
330 | |
331 /* | |
332 +-------------------------------------------------------------------+ | |
333 | PROJECT : GSM-PS (6147) MODULE : ati_src_tst | | |
334 | ROUTINE : ati_src_tst_proc_cmd | | |
335 +-------------------------------------------------------------------+ | |
336 | |
337 PURPOSE : for W32 tests | |
338 */ | |
339 | |
340 GLOBAL BOOL ati_src_tst_proc_cmd (T_ACI_CMD_REQ *aci_cmd_req) | |
341 { | |
342 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, tst_src_id[aci_cmd_req->cmd_src - 1], search_ati_src_id); | |
343 | |
344 if ( tst_src_id[aci_cmd_req->cmd_src - 1] NEQ DTI_MNG_ID_NOTPRESENT ) | |
345 { | |
346 /* | |
347 * SKA 2002-09-11 disable echoing, else no test case pass | |
348 * the strange tst_src_id[aci_cmd_req->cmd_src - 1] has to be explained by BRZ | |
349 */ | |
350 ati_user_output_cfg[tst_src_id[aci_cmd_req->cmd_src - 1]].atE = 0; | |
351 | |
352 if (src_params->text_mode EQ CMD_MODE) | |
353 { | |
354 TRACE_FUNCTION ("ati_src_tst_proc_cmd () CMD MODE"); | |
355 | |
356 if (strchr (aci_cmd_req->cmd_seq, '\r')) | |
357 { | |
358 aci_cmd_req->cmd_seq[aci_cmd_req->cmd_len] = '\0'; | |
359 } | |
360 else | |
361 { | |
362 aci_cmd_req->cmd_seq[aci_cmd_req->cmd_len] = '\r'; /* make it V.25 ter compatible */ | |
363 aci_cmd_req->cmd_seq[(aci_cmd_req->cmd_len) + 1] = '\0'; | |
364 aci_cmd_req->cmd_len++; | |
365 } | |
366 } | |
367 else /* text has to be terminated by Ctrl-Z */ | |
368 { | |
369 TRACE_FUNCTION ("ati_src_tst_proc_cmd () TEXT MODE"); | |
370 | |
371 if (aci_cmd_req->cmd_seq[aci_cmd_req->cmd_len] NEQ 0x1a) /* Ctrl-Z */ | |
372 { | |
373 aci_cmd_req->cmd_seq[aci_cmd_req->cmd_len] = 0x1a; /* make it V.25 ter compatible */ | |
374 aci_cmd_req->cmd_seq[(aci_cmd_req->cmd_len) + 1] = '\0'; | |
375 aci_cmd_req->cmd_len++; | |
376 } | |
377 else | |
378 { | |
379 aci_cmd_req->cmd_seq[aci_cmd_req->cmd_len] = '\0'; | |
380 } | |
381 } | |
382 | |
383 return (ati_execute (tst_src_id[aci_cmd_req->cmd_src - 1], | |
384 aci_cmd_req->cmd_seq, | |
385 aci_cmd_req->cmd_len)); | |
386 } | |
387 else | |
388 { | |
389 TRACE_EVENT("ATI TST Input: wrong src_id"); | |
390 return FALSE; | |
391 } | |
392 } | |
393 | |
394 | |
395 /* | |
396 +-------------------------------------------------------------------+ | |
397 | PROJECT : GSM-PS (6147) MODULE : ati_src_tst | | |
398 | ROUTINE : ati_src_tst_abort | | |
399 +-------------------------------------------------------------------+ | |
400 | |
401 PURPOSE : for W32 tests | |
402 */ | |
403 GLOBAL BOOL ati_src_tst_abort (UBYTE src_id) | |
404 { | |
405 TRACE_FUNCTION ("ati_src_tst_abort ()"); | |
406 | |
407 return (ati_abort(tst_src_id[src_id - 1])); | |
408 } | |
409 | |
410 | |
411 /* | |
412 +-------------------------------------------------------------------+ | |
413 | PROJECT : GSM-PS (6147) MODULE : ati_src_tst | | |
414 | ROUTINE : ati_src_tst_sendString | | |
415 +-------------------------------------------------------------------+ | |
416 | |
417 PURPOSE : Provides the test-source output over ACI_CMD_IND. | |
418 Removes the separator and generates one ACI_CMD_IND | |
419 for every separated message. | |
420 | |
421 */ | |
422 GLOBAL void ati_src_tst_sendString(T_desc2 *data, UBYTE src_id) | |
423 { | |
424 CHAR *string, *pch_start, *pch_end; | |
425 | |
426 TRACE_FUNCTION ("ati_src_tst_sendString ()"); | |
427 | |
428 ACI_MALLOC(string, data->len + 1); | |
429 strncpy(string, data->buffer, data->len); | |
430 string[data->len] = '\0'; | |
431 | |
432 pch_start = string; | |
433 | |
434 while ( NULL NEQ (pch_end = strchr(pch_start, ATI_TEST_SRC_SEPARATOR)) ) | |
435 { | |
436 *pch_end = '\0'; | |
437 | |
438 /* send message to the test interface*/ | |
439 { | |
440 PALLOC (aci_cmd_ind, ACI_CMD_IND); | |
441 | |
442 aci_cmd_ind->cmd_len = strlen(pch_start); | |
443 strncpy ((CHAR*)aci_cmd_ind->cmd_seq, pch_start, aci_cmd_ind->cmd_len); | |
444 | |
445 trace_cmd_line ("ATI TST Output", pch_start, src_id, aci_cmd_ind->cmd_len); | |
446 | |
447 PSENDX (ACI, aci_cmd_ind); | |
448 } | |
449 | |
450 pch_start = pch_end + 1; | |
451 } | |
452 ACI_MFREE(string); | |
453 } | |
454 #endif /* DTI */ |