##// END OF EJS Templates
Testing frame without semicolon.
imanay -
r103:104
parent child
Show More
@@ -1,459 +1,642
1 1 /*
2 2 * Servidor.c
3 3 *
4 4 * Created on: Nov 3, 2009
5 5 * Author: Jose Francisco Quenta
6 6 *
7 7 * Se implementa:
8 8 * -Carga en memoria los apuntes contenidos en un archivo de experimentos: apunte0 -> GPIO
9 9 * -Cambio de apunte.
10 10 * -Lectura del estado actual del apunte y grabado del mismo en un archivo
11 11 */
12 12
13 13 #include <stdio.h>
14 14 #include <stdlib.h>
15 15 #include <string.h>
16 16 #include <unistd.h>
17 17 #include <errno.h>
18 18
19 19 #include <sys/types.h>
20 20 #include <sys/socket.h>
21 21 #include <netinet/in.h>
22 22 #include <arpa/inet.h>
23 23 #include <netdb.h>
24 24
25 25 #include "./Librerias/AT91gpio_Funciones.h"
26 26 #include "./Librerias/Mensajes.h"
27 27
28 28 #define PUERTO_SERVIDOR 5500
29 29 #define TAM_BUFFER 1024
30 30
31 31 #define maskc_out PC30+PC28+PC26+PC24+PC22+PC20 //MSB-UP-LSB MSB-DOWN-LSB //APUNTE
32 32
33 33 #define maskb_in PB16+PB18+PB20+PB30+PB24+PB22 //MSB-UP-LSB MSB-DOWN-LSB //VERIFICACION
34 34
35 35 #define bit_up_2 0x00010000 //Mascara de cada bit a revisar: bit_up_2 es MSB
36 36 #define bit_up_1 0x00040000
37 37 #define bit_up_0 0x00100000
38 38 #define bit_dow_2 0x40000000
39 39 #define bit_dow_1 0x01000000
40 40 #define bit_dow_0 0x00400000
41 41
42 42 #define MyID 11
43 43 #define MAXPENDING 5 /* Maximum outstanding connection requests */
44 44
45 45 char *buff_experimento= NULL;
46 46
47 47 AT91S_PIO *pioc;
48 48 AT91S_PIO *piob;
49 49
50 50 struct control_module_parameters {
51 51 char ID[20];
52 52 char param2[20];
53 53 char param3[20];
54 54 char param4[20];
55 55 };
56 56
57 57 typedef struct control_module_parameters cmp;
58 58
59
60 char *header = NULL;
61 char *TypeOfInstrument = NULL;
62 char *iDSource = NULL;
63 char *iDDestino = NULL;
64 char *len = NULL;
65 char *cmd = NULL;
66 char *rx_data = NULL;
67 char *crc = NULL;
68
59 69 cmp parameters;
60 70 /*
61 71 * Zona de declaracion de cabeceras.
62 72 */
63 73 cmp inicializa_modulo(cmp p);
64 74 int inicializa_ethernet();
65 75 int rxData(int, char*);
66 76 void txData(int, char*);
67 77 void inicializa_gpio();
68 78 void procesa_peticion(char *rx_buffer, char *tx_buffer);
69 79 int cambia_apuntamiento(char *puntero_char);
70 80 int carga_experimento(char *nombre_archivo);
71 int chequeo_sistema(char *filename, char *numero_muestras);
81 char *chequeo_sistema(char *filename, char *numero_muestras);
82 int chequeo_sistema2(char *filename, char *numero_muestras);
72 83 void recibe_experimento(char *data, char filename[]);
73 84 char* File2buffer(char *filename2, int n);
85 void SplitFrame(char *frame);
86 void procesa_peticion2(char *rx_buffer, char *tx_buffer);
74 87
75 88 /*
76 89 *
77 90 */
78 91 int main(){
79 92
80 93 int servSocket;
81 94 int clntSocket;
82 95
83 96
84 97 char *rx_buffer = (char *) malloc(TAM_BUFFER);
85 98 char *tx_buffer = (char *) malloc(TAM_BUFFER);
86 99 /* Inicializa parametros del modulo*/
87 100 parameters = inicializa_modulo(parameters);
88 printf("%s%s%s%s",parameters.ID, parameters.param2, parameters.param3, parameters.param4);
101 printf("%s\n%s\n%s\n%s\n",parameters.ID, parameters.param2, parameters.param3, parameters.param4);
89 102 /* Inicializa red*/
90 103 servSocket = inicializa_ethernet();
91 104 /* Inicializamos el puerto GPIO del sistema embebido GSBC-9260S */
92 105 inicializa_gpio();
93 106
94 107 while(1){
95 108 // RecepciΓ³n TCP de peticiΓ³n
96 109 clntSocket = rxData(servSocket, rx_buffer);
97 110 //testpoint
98 111 printf("rx:%s\n",rx_buffer);
99 112 // Procesamiento de la peticiΓ³n
100 113 procesa_peticion(rx_buffer, tx_buffer);
101 114 //testpoint
102 115 printf("tx:%s\n",tx_buffer);
103 116 // Respuesta del modulo de control
104 117 txData(clntSocket, tx_buffer);
105 118
106 119 }
107 120 }
108 121
109 122
110 123 int inicializa_ethernet(){
111 124
112 125 struct sockaddr_in inf_servidor;
113 126
114 127 int servSocket;
115 128
116 129 int resultado;
117 130
118 131 /* Haciendo la estructura local*/
119 132 memset(&inf_servidor, 0, sizeof(inf_servidor));
120 133 inf_servidor.sin_family= AF_INET;
121 134 inf_servidor.sin_port= htons(PUERTO_SERVIDOR);
122 135 inf_servidor.sin_addr.s_addr= INADDR_ANY;
123 136
124 137 /* Se establece el socket */
125 138 servSocket = socket(AF_INET,SOCK_STREAM, IPPROTO_TCP);
126 139 if (servSocket == -1){
127 140 ERROR_FATAL("No se establecio correctamente el socket: socket()\n");
128 141 exit(-1);
129 142 }
130 143
131 144 /* Se asocia el socket a un puerto y una IP */
132 145 resultado = bind(servSocket,(struct sockaddr *)&inf_servidor,sizeof(inf_servidor));
133 146 if (resultado== -1){
134 147 ERROR_FATAL("No se establecio correctamente el socket: bind()\n");
135 148 exit(-1);
136 149 }
137 150
138 151 if (listen(servSocket, MAXPENDING) < 0){
139 152 printf("listen() failed\n");
140 153 exit(-1);
141 154 }
142 155
143 156 return servSocket;
144 157
145 158 }
146 159
147 160 int rxData(int servSocket, char* rx_buffer){
148 161
149 162 int clntSocket;
150 163 struct sockaddr_in inf_cliente;
151 164 int numbytes_recibidos;
152 165 unsigned int inf_client_Len;
153 166
154 167 printf("\nEsperando solicitud de cliente...\n");
155 168
156 169 /* Set the size of the in-out parameter */
157 170 inf_client_Len = sizeof(inf_cliente);
158 171 /* Se espera hasta que un cliente se conecte */
159 172 if ((clntSocket = accept(servSocket, (struct sockaddr *) &inf_cliente,
160 173 &inf_client_Len)) < 0)
161 174 printf("accept() failed\n");
162 175
163 176 if ((numbytes_recibidos = recv(clntSocket, rx_buffer, TAM_BUFFER, 0)) < 0)
164 177 printf("recv() failed\n");
165 178
166 179 /* Se procede a procesar los datos recibidos */
167 180 rx_buffer[numbytes_recibidos]= '\0';
168 181
169 182 return clntSocket;
170 183 }
171 184
172 185 void txData(int clntSocket, char* data){
173 186
174 187 /* Echo message back to client */
175 188 if (send(clntSocket, data, strlen(data), 0) != strlen(data))
176 189 printf("send() failed\n");
177 190
178 191 close(clntSocket); /* Close client socket */
179 192 }
180 193 /*
181 194 * Esta funcion incializa el puerto GPIO
182 195 */
183 196 void inicializa_gpio(){
184 197
185 198 // Configuracion de los pines de APUNTE
186 199 pioc = pio_map(PIOC_BASE);
187 200 pio_enable(pioc, maskc_out);
188 201 pio_disable_irq(pioc, maskc_out);
189 202 pio_disable_multiple_driver(pioc, maskc_out);
190 203 pio_disable_pull_ups(pioc, maskc_out);
191 204 pio_synchronous_data_output(pioc, maskc_out);
192 205 pio_output_enable(pioc, maskc_out);
193 206
194 207 // Configuracion de los pines de VERIFICACION
195 208 piob = pio_map(PIOB_BASE);
196 209 pio_enable(piob, maskb_in);
197 210 pio_disable_irq(piob, maskb_in);
198 211 pio_disable_multiple_driver(piob, maskb_in);
199 212 pio_disable_pull_ups(piob, maskb_in);
200 213 pio_input_enable(piob, maskb_in);
201 214
202 215 }
203 216
204 217 /*
205 218 * Esta funcion procesa el mensaje de peticion y genera respuesta
206 219 */
207 void procesa_peticion(char *rx_buffer, char *tx_buffer){
220 void procesa_peticion2(char *rx_buffer, char *tx_buffer){
208 221 int n = 0;
209 222 char filename1[50];
210 223 char filename2[] = "verificacion.txt";
211 224 char *tx_data = NULL;
212 225 char *header = strtok(rx_buffer, ":");
213 226 char *TypeOfInstrument = strtok(NULL, ":");
214 227 char *iDSource = strtok(NULL, ":");
215 228 char *iDDestino = strtok(NULL, ":");
216 229 char *len = strtok(NULL, ":");
217 230 char *cmd = strtok(NULL, ":");
218 231 char *rx_data = strtok(NULL, ":");
219 232 char *crc = strtok(NULL, ":");
220 233
221 234 if ((cmd == NULL) || (rx_data == NULL)){
222 235 ERROR("procesarPeticion: formato de mensaje incorrecto");
223 236 }
224 237 else{
225 238 if(strcmp(cmd,"SNDF") == 0){
226 239 recibe_experimento(rx_data,filename1);
227 240 carga_experimento(filename1);
228 241 cambia_apuntamiento("0");
229 242 tx_data = (char*)malloc(3);
230 243 tx_data = "OK";
231 244 }
232 245 else if(strcmp(cmd,"CHGB") == 0){
233 246 cambia_apuntamiento(rx_data);
234 247 tx_data = (char*)malloc(3);
235 248 tx_data = "OK";
236 249
237 250 }
238 251
239 252 else if(strcmp(cmd,"ANST") == 0){
240 n = chequeo_sistema(filename2,rx_data);
253 n = chequeo_sistema2(filename2,rx_data);
241 254 printf("%i\n",n);
242 255 tx_data = File2buffer(filename2, n);
243 256 }
244 257 else{
245 258 tx_data = (char*)malloc(6);
246 259 tx_data = "Error";
247 260 ERROR("procesa_peticion: comando no reconocido");
248 261 }
249 262
250 263 strcpy(tx_buffer,header);
251 264 strcat(tx_buffer,":");
252 265 strcat(tx_buffer,TypeOfInstrument);
253 266 strcat(tx_buffer,":");
254 267 strcat(tx_buffer,iDDestino);
255 268 strcat(tx_buffer,":");
256 269 strcat(tx_buffer,iDSource);
257 270 strcat(tx_buffer,":");
258 271 strcat(tx_buffer,len);
259 272 strcat(tx_buffer,":");
260 273 strcat(tx_buffer,cmd);
261 274 strcat(tx_buffer,":");
262 275 strcat(tx_buffer,tx_data);
263 276 strcat(tx_buffer,":");
264 277 strcat(tx_buffer,crc);
265 278 strcat(tx_buffer,":");
266 279 strcat(tx_buffer,"quit");
280 }
281 }
282
283 void SplitFrame(char *frame){
284 header = malloc(4);
285 *header = *frame;
286 *(header + 1) = *(frame + 1);
287 *(header + 2) = *(frame + 2);
288 *(header + 3) = '\0';
289 TypeOfInstrument = malloc(4);
290 *TypeOfInstrument = *(frame + 3);
291 *(TypeOfInstrument + 1) = *(frame + 4);
292 *(TypeOfInstrument + 2) = *(frame + 5);
293 *(TypeOfInstrument + 3) = '\0';
294 iDSource = malloc(8);
295 *iDSource = *(frame + 6);
296 *(iDSource + 1) = *(frame + 7);
297 *(iDSource + 2) = *(frame + 8);
298 *(iDSource + 3) = *(frame + 9);
299 *(iDSource + 4) = *(frame + 10);
300 *(iDSource + 5) = *(frame + 11);
301 *(iDSource + 6) = *(frame + 12);
302 *(iDSource + 7) = '\0';
303 iDDestino = malloc(8);
304 *iDDestino = *(frame + 13);
305 *(iDDestino + 1) = *(frame + 14);
306 *(iDDestino + 2) = *(frame + 15);
307 *(iDDestino + 3) = *(frame + 16);
308 *(iDDestino + 4) = *(frame + 17);
309 *(iDDestino + 5) = *(frame + 18);
310 *(iDDestino + 6) = *(frame + 19);
311 *(iDDestino + 7) = '\0';
312 len = malloc(7);
313 *len = *(frame + 20);
314 *(len + 1) = *(frame + 21);
315 *(len + 2) = *(frame + 22);
316 *(len + 3) = *(frame + 23);
317 *(len + 4) = *(frame + 24);
318 *(len + 5) = *(frame + 25);
319 *(len + 6) = '\0';
320 cmd = malloc(5);
321 *cmd = *(frame + 26);
322 *(cmd + 1) = *(frame + 27);
323 *(cmd + 2) = *(frame + 28);
324 *(cmd + 3) = *(frame + 29);
325 *(cmd + 4) = '\0';
326
327 int l = atoi(len) - 31; //Resto del tamaΓ±o total de la trama los 31 bytes fijos
328 rx_data = malloc(l);
329 int i;
330 for (i = 30; i < 30 + l; i++)
331 *(rx_data + (i-30)) = *(frame + i);
332 *(rx_data + l) = '\0';
333 crc = malloc(2);
334 *crc = *(frame + 30 + l);
335 *(crc + 1) = '\0';
336 }
337
338 void procesa_peticion(char *rx_buffer, char *tx_buffer){
339 // int n = 0;
340 char filename1[50];
341 char filename2[] = "verificacion.txt";
342 char *tx_data = NULL;
343 SplitFrame(rx_buffer);
344 printf("Split\n");
345 printf("%s\n",header);
346 printf("%s\n",TypeOfInstrument);
347 printf("%s\n",iDSource);
348 printf("%s\n",iDDestino);
349 printf("%s\n",len);
350 printf("%s\n",cmd);
351 printf("%s\n",rx_data);
352 printf("%s\n",crc);
353 printf("Split\n");
354
355 if ((cmd == NULL) || (rx_data == NULL)){
356 ERROR("procesarPeticion: formato de mensaje incorrecto");
357 }
358 else{
359 if(strcmp(cmd,"SNDF") == 0){
360 recibe_experimento(rx_data,filename1);
361 carga_experimento(filename1);
362 cambia_apuntamiento("0");
363 tx_data = (char*)malloc(3);
364 tx_data = "OK";
365 }
366 else if(strcmp(cmd,"CHGB") == 0){
367 cambia_apuntamiento(rx_data);
368 tx_data = (char*)malloc(3);
369 tx_data = "OK";
370
371 }
372
373 else if(strcmp(cmd,"ANST") == 0){
374 /*n = chequeo_sistema(filename2,rx_data);
375 printf("%i\n",n);
376 tx_data = File2buffer(filename2, n);*/
377 tx_data = chequeo_sistema(filename2,rx_data);
378 printf("%s\n",tx_data);
379 }
380 else{
381 tx_data = (char*)malloc(6);
382 tx_data = "Error";
383 ERROR("procesa_peticion: comando no reconocido");
384 }
385
386 strcpy(tx_buffer,header); //3
387 strcat(tx_buffer,TypeOfInstrument); //3
388 strcat(tx_buffer,parameters.ID); //7
389 strcat(tx_buffer,iDSource); //7
390 strcat(tx_buffer,"00032"); //5
391 strcat(tx_buffer,cmd); //4
392 strcat(tx_buffer,tx_data); //2
393 strcat(tx_buffer,crc); //1
267 394
268 395 }
269 396
270 397 }
271 398
272 399 /*
273 400 * Esta funciΓ³n genera el archivo de experimento a partir de la trama TCP recibida
274 401 */
275 402
276 403 void recibe_experimento(char *p_data, char filename[]){
277 404 FILE *fd;
278 405 int i = 0;
279 406
280 407 while (*p_data != '\n'){
281 408 filename[i] = *p_data;
282 409 i++;
283 410 p_data++;
284 411 }
285 412 filename[i] = '\0';
286 413 p_data = p_data - i;
287 414 fd = fopen(filename,"w");
288 415 fprintf(fd, p_data);
289 416 fclose(fd);
290 417 }
291 418
292 419 /*
293 420 * Esta funcion carga un archivo en un buffer que esta ubicado en memoria, luego
294 421 * este buffer es usado en la funcion "cambia_apuntamiento" para obtener el dato
295 422 * que sera usado en el cambio de apuntamiento.
296 423 */
297 424 int carga_experimento(char *nombre_archivo){
298 425
299 426 FILE *Archivo_Fd;
300 427
301 428 char *cadena = (char *) malloc(25);
302 429
303 430 int longitud_cadena;
304 431 int num_bytes= 0;
305 432 int num_filas= 0;
306 433
307 434 Archivo_Fd = fopen(nombre_archivo,"r"); // Se procede a abrir el archivo, segun la ruta especificada
308 435 if(!Archivo_Fd){
309 436 ERROR("carga_archivo: No se pudo abrir el archivo!!! --> fopen()\n");
310 437 return -1;
311 438 }else{
312 439
313 440 while(!feof(Archivo_Fd)){ // Se procede a calcular la longitud del archivo para separar memoria
314 441 fgets(cadena,20,Archivo_Fd);
315 442 longitud_cadena= strlen(cadena);
316 443 cadena[longitud_cadena-1] = '\0';
317 444 num_bytes = num_bytes + longitud_cadena;
318 445 num_filas++;
319 446 }
320 447
321 448 rewind(Archivo_Fd); // Se reinicia el puntero del archivo
322 449
323 450 char *buffer_temporal = (char *) malloc(num_bytes+1); // Se separa espacio de memoria segun
324 451 // la longitud del archivo
325 452 fread(buffer_temporal, sizeof(char), num_bytes, Archivo_Fd);
326 453
327 454 char *puntero= strstr(buffer_temporal,".ab1"); // Se procede a eliminar la cabecera del archivo
328 455 puntero= puntero + 12;
329 456
330 457 buff_experimento = (char *) malloc(7*(num_filas-3)); // num_bytes_fila*(num_filas-3);
331 458 strncpy(buff_experimento,puntero,7*(num_filas-3)); // Se carga en memoria la informacion del archivo
332 459
333 460 fclose(Archivo_Fd);
334 461
335 462 return 1;
336 463 }
337 464 }
338 465
339 466 /*
340 467 * Esta funcion recibe un numero en formato char, el dato se transforma a su equivalente en
341 468 * un numero entero, que sera usado para sacar un dato del buffer "buff_experimento", esta
342 469 * dato es el valor que se enviara al sistema de conmutacion RF para el cambio de apunte a
343 470 * traves del puerto GPIO.
344 471 */
345 472 int cambia_apuntamiento(char *puntero_char){
346 473
347 474 /*MSB-UP-LSB MSB-DOWN-LSB*/
348 475 int desplazamiento[6]={30,28,26,24,22,20}; // Defino los dezplazamientos que se aplicara
349 476 // al dato que ingresa para formar el nΓΊmero
350 477 // entero que se le pasara al puerto GPIO
351 478 // Estos nΓΊmeros son los pines del puerto GPIO
352 479 // que se estan usando para el control
353 480
354 481 int puntero= atoi(puntero_char); // Se convierte a entero la direccion del puntero
355 482
356 483 int base= 7*puntero; // base= cantidad_bytes del dato x puntero
357 484 // cantidad de bytes es el numero de bytes que
358 485 printf("%s\n",puntero_char); // contiene cada dato, para este caso es 7
359 486 // porque es 6 bits de datos + 1 bit del cambio
360 487 // de linea.
361 488 char valor_char;
362 489 unsigned long valor;
363 490 unsigned long acumulado_ceros=0;
364 491 unsigned long acumulado_unos=0;
365 492
366 493 int offset; // Defino offset para el desplazamiento a traves
367 494 for(offset=0;offset<6;offset++){ // de cada dato que se obtiene del "buff_experimento"
368 495
369 496 valor_char= buff_experimento[base+offset]; // Obtengo el dato
370 497
371 498 if (valor_char == '0'){ // Obtengo el nΓΊmero acumulado segun sea un cero o un uno
372 499 valor= 0;
373 500 acumulado_ceros= acumulado_ceros + (1 << desplazamiento[offset]);
374 501 }else{
375 502 valor= 1;
376 503 acumulado_unos= acumulado_unos + (1 << desplazamiento[offset]);
377 504 }
378 505 }
379 506 pio_out(pioc, maskc_out, acumulado_unos, 1);
380 507 pio_out(pioc, maskc_out, acumulado_ceros, 0);
381 508
382 509 return 1;
383 510
384 511 }
385 512
386 513 /*
387 514 * Esta funcion lee "n" veces el estado del APUNTE actual y lo guarda en el
388 515 * archivo Verificacion.
389 516 */
390 517
391 int chequeo_sistema(char *filename, char *numero_muestras){
518 int chequeo_sistema2(char *filename, char *numero_muestras){
392 519
393 520 char valor[7];
394 521 int i,cnt;
395 522 unsigned int entradac= 0;
396 523 FILE *fd;
397 524 fd=fopen(filename,"w");
398 525 fprintf(fd,"%s\n","Verificacion");
399 fprintf(fd,"%s",parameters.ID);
526 fprintf(fd,"%s\n",parameters.ID);
400 527 fprintf(fd,"%s\n","------------");
401 528 cnt=0;
402 529 do
403 530 {
404 531 //Inicializando arreglo
405 532 for(i=0;i<6;i++)
406 533 valor[i]='0';
407 534
408 535 valor[6]='\0';
409 536
410 537 //Lectura de puerto
411 538 entradac= pio_in(piob,maskb_in);
412 539
413 540 //Dandole formato al dato
414 541 if (!(entradac & bit_up_2))
415 542 valor[0] = '1';
416 543 if (!(entradac & bit_up_1))
417 544 valor[1] = '1';
418 545 if (!(entradac & bit_up_0))
419 546 valor[2] = '1';
420 547 if (!(entradac & bit_dow_2))
421 548 valor[3] = '1';
422 549 if (!(entradac & bit_dow_1))
423 550 valor[4] = '1';
424 551 if (!(entradac & bit_dow_0))
425 552 valor[5] = '1';
426 553
427 554 //Escribiendo en archivo
428 555 fprintf(fd,"%s\n",valor);
429 556 cnt=cnt+1;
430 557 usleep(1*1000*1000);
431 558
432 559 }while(cnt < atoi(numero_muestras));
433 560
434 561 fclose(fd);
435 562
436 563 return 7*atoi(numero_muestras) + 26 + 4 + 1; //incluye eof
437 564 }
438 565
439 566 char* File2buffer(char *filename, int n){
440 567 FILE *fd;
441 568 char* tx_data = (char *)malloc(n);
442 569 fd = fopen(filename,"r");
443 570 fread(tx_data, 1, n-1, fd);
444 571 fclose(fd);
445 572 tx_data = tx_data + n - 1;
446 573 *tx_data = '\0';
447 574 tx_data = tx_data - n + 1;
448 575 return tx_data;
449 576 }
450 577
578 /*
579 * Esta funcion lee "n" veces el estado del APUNTE actual y reporta
580 * una cadena de Verificacion.
581 */
582 char* chequeo_sistema(char *filename, char *numero_muestras){
583
584 int i;
585 int cnt = 0;
586 unsigned int entradac= 0;
587
588 char page0[250];
589
590 strcpy(page0,"Verificacion\n");
591 strcat(page0,parameters.ID);
592 strcat(page0,"\n------------\n");
593
594 char page1[8];
595
596 do{
597 //Inicializando arreglo
598 for(i=0;i<6;i++)
599 page1[i]='0';
600 page1[6] = '\n';
601 page1[7] = '\0';
602 //Lectura de puerto
603 entradac= pio_in(piob,maskb_in);
604 //Dandole formato al dato
605 if (!(entradac & bit_up_2))
606 page1[0] = '1';
607 if (!(entradac & bit_up_1))
608 page1[1] = '1';
609 if (!(entradac & bit_up_0))
610 page1[2] = '1';
611 if (!(entradac & bit_dow_2))
612 page1[3] = '1';
613 if (!(entradac & bit_dow_1))
614 page1[4] = '1';
615 if (!(entradac & bit_dow_0))
616 page1[5] = '1';
617
618 strcat(page0, page1);
619 cnt=cnt+1;
620 usleep(1*1000*1000);
621
622 }while(cnt < atoi(numero_muestras));
623
624 page0[strlen(page0)] = '\0';
625
626 char *all_pages = malloc(strlen(page0)+1);
627 strcpy(all_pages, page0);
628 return all_pages;
629 }
451 630 cmp inicializa_modulo(cmp p){
452 631 FILE *fd = fopen("configuration.txt","r");
453 632 fgets(p.ID,20,fd);
633 p.ID[7]='\0';
454 634 fgets(p.param2,20,fd);
635 p.param2[10]='\0';
455 636 fgets(p.param3,20,fd);
637 p.param3[10]='\0';
456 638 fgets(p.param4,20,fd);
639 p.param4[10]='\0';
457 640 fclose(fd);
458 641 return p;
459 642 }
General Comments 0
You need to be logged in to leave comments. Login now