@@ -0,0 +1,324 | |||
|
1 | /* | |
|
2 | * Servidor.c | |
|
3 | * | |
|
4 | * Created on: Nov 3, 2009 | |
|
5 | * Author: Jose Francisco Quenta | |
|
6 | * | |
|
7 | * Se implementa: | |
|
8 | * -Carga en memoria los apuntes contenidos en un archivo de experimentos: apunte0 -> GPIO | |
|
9 | * -Cambio de apunte. | |
|
10 | * -Lectura del estado actual del apunte y grabado del mismo en un archivo | |
|
11 | */ | |
|
12 | ||
|
13 | #include <stdio.h> | |
|
14 | #include <stdlib.h> | |
|
15 | #include <string.h> | |
|
16 | #include <unistd.h> | |
|
17 | #include <errno.h> | |
|
18 | ||
|
19 | #include <sys/types.h> | |
|
20 | #include <sys/socket.h> | |
|
21 | #include <netinet/in.h> | |
|
22 | #include <arpa/inet.h> | |
|
23 | #include <netdb.h> | |
|
24 | ||
|
25 | #include "./Librerias/AT91gpio_Funciones.h" | |
|
26 | #include "./Librerias/Mensajes.h" | |
|
27 | ||
|
28 | #define PUERTO_SERVIDOR 5500 | |
|
29 | #define TAM_BUFFER 100 | |
|
30 | ||
|
31 | #define maskc_out PC30+PC28+PC26+PC24+PC22+PC20 //MSB-UP-LSB MSB-DOWN-LSB //APUNTE | |
|
32 | ||
|
33 | #define maskb_in PB16+PB18+PB20+PB30+PB24+PB22 //MSB-UP-LSB MSB-DOWN-LSB //VERIFICACION | |
|
34 | ||
|
35 | #define bit_up_2 0x00010000 //Mascara de cada bit a revisar: bit_up_2 es MSB | |
|
36 | #define bit_up_1 0x00040000 | |
|
37 | #define bit_up_0 0x00100000 | |
|
38 | #define bit_dow_2 0x40000000 | |
|
39 | #define bit_dow_1 0x01000000 | |
|
40 | #define bit_dow_0 0x00400000 | |
|
41 | ||
|
42 | #define MyID 11 | |
|
43 | ||
|
44 | char *buff_experimento= NULL; | |
|
45 | ||
|
46 | AT91S_PIO *pioc; | |
|
47 | AT91S_PIO *piob; | |
|
48 | ||
|
49 | /* | |
|
50 | * Zona de declaracion de cabeceras. | |
|
51 | */ | |
|
52 | void inicializa_gpio(); | |
|
53 | int procesa_peticion(char *buff_peticion); | |
|
54 | int cambia_apuntamiento(char *puntero_char); | |
|
55 | int carga_experimento(char *nombre_archivo); | |
|
56 | int chequeo_sistema(char *numero_muestras); | |
|
57 | ||
|
58 | /* | |
|
59 | * | |
|
60 | */ | |
|
61 | int main(){ | |
|
62 | ||
|
63 | int conexion_servidorFd; | |
|
64 | struct sockaddr_in inf_servidor; | |
|
65 | struct sockaddr_storage inf_cliente; | |
|
66 | int resultado; | |
|
67 | int numbytes_recibidos; | |
|
68 | int rpta; | |
|
69 | ||
|
70 | char *buff_peticion = (char *) malloc(TAM_BUFFER); | |
|
71 | ||
|
72 | size_t addr_len; | |
|
73 | ||
|
74 | memset(&inf_servidor, 0, sizeof(inf_servidor)); | |
|
75 | inf_servidor.sin_family= AF_INET; | |
|
76 | inf_servidor.sin_port= htons(PUERTO_SERVIDOR); | |
|
77 | inf_servidor.sin_addr.s_addr= INADDR_ANY; | |
|
78 | ||
|
79 | /* Se establece el socket */ | |
|
80 | conexion_servidorFd = socket(AF_INET,SOCK_DGRAM,0); | |
|
81 | if (conexion_servidorFd == -1){ | |
|
82 | ERROR_FATAL("No se establecio correctamente el socket: socket()"); | |
|
83 | } | |
|
84 | ||
|
85 | /* Se asocia el socket a un puerto y una IP */ | |
|
86 | resultado = bind(conexion_servidorFd,(struct sockaddr *)&inf_servidor,sizeof(inf_servidor)); | |
|
87 | if (resultado== -1){ | |
|
88 | ERROR_FATAL("No se establecio correctamente el socket: bind()"); | |
|
89 | } | |
|
90 | ||
|
91 | /* Inicializamos el puerto GPIO del sistema embebido GSBC-9260S */ | |
|
92 | inicializa_gpio(); | |
|
93 | ||
|
94 | while(1){ | |
|
95 | LOG_SERVIDOR("Esperando solicitud de cliente...\n"); | |
|
96 | ||
|
97 | /* Se espera hasta que un cliente se conecte */ | |
|
98 | addr_len = sizeof(inf_cliente); | |
|
99 | numbytes_recibidos = recvfrom(conexion_servidorFd, buff_peticion, TAM_BUFFER-1, 0, (struct sockaddr *)&inf_cliente, &addr_len); | |
|
100 | if (numbytes_recibidos == -1){ | |
|
101 | ERROR_FATAL("Error en la recepcion de datos: recvfrom()"); | |
|
102 | } | |
|
103 | ||
|
104 | /* Se procede a procesar los datos recibidos */ | |
|
105 | buff_peticion[numbytes_recibidos]= '\0'; | |
|
106 | ||
|
107 | /* procesamiento de la peticion */ | |
|
108 | rpta = procesa_peticion(buff_peticion); | |
|
109 | ||
|
110 | //Respuesta del modulo de control | |
|
111 | // | |
|
112 | ||
|
113 | ||
|
114 | } | |
|
115 | } | |
|
116 | ||
|
117 | ||
|
118 | ||
|
119 | /* | |
|
120 | * Esta funcion incializa el puerto GPIO | |
|
121 | */ | |
|
122 | void inicializa_gpio(){ | |
|
123 | ||
|
124 | // Configuracion de los pines de APUNTE | |
|
125 | pioc = pio_map(PIOC_BASE); | |
|
126 | pio_enable(pioc, maskc_out); | |
|
127 | pio_disable_irq(pioc, maskc_out); | |
|
128 | pio_disable_multiple_driver(pioc, maskc_out); | |
|
129 | pio_disable_pull_ups(pioc, maskc_out); | |
|
130 | pio_synchronous_data_output(pioc, maskc_out); | |
|
131 | pio_output_enable(pioc, maskc_out); | |
|
132 | ||
|
133 | // Configuracion de los pines de VERIFICACION | |
|
134 | piob = pio_map(PIOB_BASE); | |
|
135 | pio_enable(piob, maskb_in); | |
|
136 | pio_disable_irq(piob, maskb_in); | |
|
137 | pio_disable_multiple_driver(piob, maskb_in); | |
|
138 | pio_disable_pull_ups(piob, maskb_in); | |
|
139 | pio_input_enable(piob, maskb_in); | |
|
140 | ||
|
141 | } | |
|
142 | ||
|
143 | /* | |
|
144 | * Esta funcion procesa el mensaje de peticion y genera respuesta | |
|
145 | */ | |
|
146 | int procesa_peticion(char *buff_peticion){ | |
|
147 | int rpta; | |
|
148 | // char *header = strtok(buff_peticion, ":"); | |
|
149 | // char *ipSource = strtok(buff_peticion, ":"); | |
|
150 | // char *ipDestino = strtok(buff_peticion, ":"); | |
|
151 | char *comando = strtok(buff_peticion, ":"); | |
|
152 | char *valor = strtok(NULL, ":"); | |
|
153 | ||
|
154 | if ((comando == NULL) || (valor == NULL)){ | |
|
155 | ERROR("procesarPeticion: formato de mensaje incorrecto"); | |
|
156 | } | |
|
157 | else{ | |
|
158 | if(strcmp(comando,"CARGA") == 0) | |
|
159 | rpta = carga_experimento(valor); | |
|
160 | else if(strcmp(comando,"CAMBIA") == 0) | |
|
161 | rpta = cambia_apuntamiento(valor); | |
|
162 | else if(strcmp(comando,"CHEQUEO") == 0) | |
|
163 | rpta = chequeo_sistema(valor); | |
|
164 | else | |
|
165 | ERROR("procesa_peticion: comando no reconocido"); | |
|
166 | } | |
|
167 | ||
|
168 | return rpta; | |
|
169 | } | |
|
170 | ||
|
171 | ||
|
172 | /* | |
|
173 | * Esta funcion carga un archivo en un buffer que esta ubicado en memoria, luego | |
|
174 | * este buffer es usado en la funcion "cambia_apuntamiento" para obtener el dato | |
|
175 | * que sera usado en el cambio de apuntamiento. | |
|
176 | */ | |
|
177 | int carga_experimento(char *nombre_archivo){ | |
|
178 | ||
|
179 | FILE *Archivo_Fd; | |
|
180 | ||
|
181 | char *cadena = (char *) malloc(25); | |
|
182 | ||
|
183 | int longitud_cadena; | |
|
184 | int num_bytes= 0; | |
|
185 | int num_filas= 0; | |
|
186 | ||
|
187 | char ruta_archivo[50]; // Se crea la ruta para abrir el archivo | |
|
188 | strcpy(ruta_archivo,"/mnt/sd/archivos/"); | |
|
189 | strcat(ruta_archivo,nombre_archivo); | |
|
190 | ||
|
191 | Archivo_Fd = fopen(ruta_archivo,"r"); // Se procede a abrir el archivo, segun la ruta especificada | |
|
192 | if(!Archivo_Fd){ | |
|
193 | ERROR("carga_archivo: No se pudo abrir el archivo!!! --> fopen()\n"); | |
|
194 | return -1; | |
|
195 | }else{ | |
|
196 | ||
|
197 | while(!feof(Archivo_Fd)){ // Se procede a calcular la longitud del archivo para separar memoria | |
|
198 | fgets(cadena,20,Archivo_Fd); | |
|
199 | longitud_cadena= strlen(cadena); | |
|
200 | cadena[longitud_cadena-1] = '\0'; | |
|
201 | num_bytes = num_bytes + longitud_cadena; | |
|
202 | num_filas++; | |
|
203 | } | |
|
204 | ||
|
205 | rewind(Archivo_Fd); // Se reinicia el puntero del archivo | |
|
206 | ||
|
207 | char *buffer_temporal = (char *) malloc(num_bytes+1); // Se separa espacio de memoria segun | |
|
208 | // la longitud del archivo | |
|
209 | fread(buffer_temporal, sizeof(char), num_bytes, Archivo_Fd); | |
|
210 | ||
|
211 | char *puntero= strstr(buffer_temporal,".abs"); // Se procede a eliminar la cabecera del archivo | |
|
212 | puntero= puntero + 12; | |
|
213 | ||
|
214 | buff_experimento = (char *) malloc(7*(num_filas-3)); // num_bytes_fila*(num_filas-3); | |
|
215 | strncpy(buff_experimento,puntero,7*(num_filas-3)); // Se carga en memoria la informacion del archivo | |
|
216 | ||
|
217 | fclose(Archivo_Fd); | |
|
218 | ||
|
219 | cambia_apuntamiento("0"); // Se apunta a la direccion 0 | |
|
220 | ||
|
221 | return 1; | |
|
222 | } | |
|
223 | } | |
|
224 | ||
|
225 | /* | |
|
226 | * Esta funcion recibe un numero en formato char, el dato se transforma a su equivalente en | |
|
227 | * un numero entero, que sera usado para sacar un dato del buffer "buff_experimento", esta | |
|
228 | * dato es el valor que se enviara al sistema de conmutacion RF para el cambio de apunte a | |
|
229 | * traves del puerto GPIO. | |
|
230 | */ | |
|
231 | int cambia_apuntamiento(char *puntero_char){ | |
|
232 | ||
|
233 | /*MSB-UP-LSB MSB-DOWN-LSB*/ | |
|
234 | int desplazamiento[6]={30,28,26,24,22,20}; // Defino los dezplazamientos que se aplicara | |
|
235 | // al dato que ingresa para formar el número | |
|
236 | // entero que se le pasara al puerto GPIO | |
|
237 | // Estos números son los pines del puerto GPIO | |
|
238 | // que se estan usando para el control | |
|
239 | ||
|
240 | int puntero= atoi(puntero_char); // Se convierte a entero la direccion del puntero | |
|
241 | ||
|
242 | int base= 7*puntero; // base= cantidad_bytes del dato x puntero | |
|
243 | // cantidad de bytes es el numero de bytes que | |
|
244 | printf("%i\n",puntero); // contiene cada dato, para este caso es 7 | |
|
245 | // porque es 6 bits de datos + 1 bit del cambio | |
|
246 | // de linea. | |
|
247 | char valor_char; | |
|
248 | unsigned long valor; | |
|
249 | unsigned long acumulado_ceros=0; | |
|
250 | unsigned long acumulado_unos=0; | |
|
251 | ||
|
252 | int offset; // Defino offset para el desplazamiento a traves | |
|
253 | for(offset=0;offset<6;offset++){ // de cada dato que se obtiene del "buff_experimento" | |
|
254 | ||
|
255 | valor_char= buff_experimento[base+offset]; // Obtengo el dato | |
|
256 | ||
|
257 | if (valor_char == '0'){ // Obtengo el número acumulado segun sea un cero o un uno | |
|
258 | valor= 0; | |
|
259 | acumulado_ceros= acumulado_ceros + (1 << desplazamiento[offset]); | |
|
260 | }else{ | |
|
261 | valor= 1; | |
|
262 | acumulado_unos= acumulado_unos + (1 << desplazamiento[offset]); | |
|
263 | } | |
|
264 | ||
|
265 | } | |
|
266 | ||
|
267 | pio_out(pioc, maskc_out, acumulado_unos, 1); | |
|
268 | pio_out(pioc, maskc_out, acumulado_ceros, 0); | |
|
269 | ||
|
270 | return 1; | |
|
271 | ||
|
272 | } | |
|
273 | ||
|
274 | /* | |
|
275 | * Esta funcion lee "n" veces el estado del APUNTE actual y lo guarda en el | |
|
276 | * archivo Verificacion. | |
|
277 | */ | |
|
278 | ||
|
279 | int chequeo_sistema(char *numero_muestras){ | |
|
280 | ||
|
281 | char valor[7]; | |
|
282 | int i,cnt; | |
|
283 | unsigned int entradac= 0; | |
|
284 | FILE *fd; | |
|
285 | fd=fopen("/mnt/sd/archivos/Verificacion","w"); | |
|
286 | fprintf(fd,"%s\n","Verificacion"); | |
|
287 | fprintf(fd,"%s\n","------------"); | |
|
288 | cnt=0; | |
|
289 | do | |
|
290 | { | |
|
291 | //Inicializando arreglo | |
|
292 | for(i=0;i<6;i++) | |
|
293 | valor[i]='0'; | |
|
294 | ||
|
295 | valor[6]='\0'; | |
|
296 | ||
|
297 | //Lectura de puerto | |
|
298 | entradac= pio_in(piob,maskb_in); | |
|
299 | ||
|
300 | //Dandole formato al dato | |
|
301 | if (!(entradac & bit_up_2)) | |
|
302 | valor[0] = '1'; | |
|
303 | if (!(entradac & bit_up_1)) | |
|
304 | valor[1] = '1'; | |
|
305 | if (!(entradac & bit_up_0)) | |
|
306 | valor[2] = '1'; | |
|
307 | if (!(entradac & bit_dow_2)) | |
|
308 | valor[3] = '1'; | |
|
309 | if (!(entradac & bit_dow_1)) | |
|
310 | valor[4] = '1'; | |
|
311 | if (!(entradac & bit_dow_0)) | |
|
312 | valor[5] = '1'; | |
|
313 | ||
|
314 | //Escribiendo en archivo | |
|
315 | fprintf(fd,"%s\n",valor); | |
|
316 | cnt=cnt+1; | |
|
317 | usleep(1*1000*1000); | |
|
318 | ||
|
319 | }while(cnt < atoi(numero_muestras)); | |
|
320 | ||
|
321 | fclose(fd); | |
|
322 | ||
|
323 | return 1; | |
|
324 | } |
@@ -15,7 +15,7 | |||
|
15 | 15 | </extensions> |
|
16 | 16 | </storageModule> |
|
17 | 17 | <storageModule moduleId="cdtBuildSystem" version="4.0.0"> |
|
18 | <configuration artifactName="Control_Module" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.1568263498" name="Release" parent="cdt.managedbuild.config.gnu.exe.release"> | |
|
18 | <configuration artifactName="Control_Module_v1_debug" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.1568263498" name="Release" parent="cdt.managedbuild.config.gnu.exe.release"> | |
|
19 | 19 | <folderInfo id="cdt.managedbuild.config.gnu.exe.release.1568263498." name="/" resourcePath=""> |
|
20 | 20 | <toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.785297601" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release"> |
|
21 | 21 | <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.1008424557" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/> |
@@ -35,6 +35,7 | |||
|
35 | 35 | <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> |
|
36 | 36 | <additionalInput kind="additionalinput" paths="$(LIBS)"/> |
|
37 | 37 | </inputType> |
|
38 | <outputType id="cdt.managedbuild.tool.gnu.c.linker.output.439510446" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.c.linker.output"/> | |
|
38 | 39 | </tool> |
|
39 | 40 | <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.1068281678" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release"/> |
|
40 | 41 | <tool id="cdt.managedbuild.tool.gnu.assembler.exe.release.796779267" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release"> |
@@ -44,6 +45,11 | |||
|
44 | 45 | </folderInfo> |
|
45 | 46 | </configuration> |
|
46 | 47 | </storageModule> |
|
48 | ||
|
49 | <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> | |
|
50 | <storageModule moduleId="org.eclipse.cdt.core.language.mapping"/> | |
|
51 | <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/> | |
|
52 | <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/> | |
|
47 | 53 | <storageModule moduleId="scannerConfiguration"> |
|
48 | 54 | <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/> |
|
49 | 55 | <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> |
@@ -210,7 +216,6 | |||
|
210 | 216 | </profile> |
|
211 | 217 | </scannerConfigBuildInfo> |
|
212 | 218 | </storageModule> |
|
213 | <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> | |
|
214 | 219 | </cconfiguration> |
|
215 | 220 | </storageModule> |
|
216 | 221 | <storageModule moduleId="cdtBuildSystem" version="4.0.0"> |
@@ -50,10 +50,14 | |||
|
50 | 50 | * Zona de declaracion de cabeceras. |
|
51 | 51 | */ |
|
52 | 52 | void inicializa_gpio(); |
|
53 | int procesa_peticion(char *buff_peticion); | |
|
54 | int cambia_apuntamiento(char *puntero_char); | |
|
55 |
int ca |
|
|
56 | int chequeo_sistema(char *numero_muestras); | |
|
53 | //int procesa_peticion(char *buff_peticion); | |
|
54 | void procesa_peticion(char *buff_peticion); | |
|
55 | //int cambia_apuntamiento(char *puntero_char); | |
|
56 | void cambia_apuntamiento(char *puntero_char); | |
|
57 | //int carga_experimento(char *nombre_archivo); | |
|
58 | void carga_experimento(char *nombre_archivo); | |
|
59 | //int chequeo_sistema(char *numero_muestras); | |
|
60 | void chequeo_sistema(char *numero_muestras); | |
|
57 | 61 | |
|
58 | 62 | /* |
|
59 | 63 | * |
@@ -65,7 +69,7 | |||
|
65 | 69 | struct sockaddr_storage inf_cliente; |
|
66 | 70 | int resultado; |
|
67 | 71 | int numbytes_recibidos; |
|
68 | int rpta; | |
|
72 | //int rpta; | |
|
69 | 73 | |
|
70 | 74 | char *buff_peticion = (char *) malloc(TAM_BUFFER); |
|
71 | 75 | |
@@ -99,13 +103,16 | |||
|
99 | 103 | numbytes_recibidos = recvfrom(conexion_servidorFd, buff_peticion, TAM_BUFFER-1, 0, (struct sockaddr *)&inf_cliente, &addr_len); |
|
100 | 104 | if (numbytes_recibidos == -1){ |
|
101 | 105 | ERROR_FATAL("Error en la recepcion de datos: recvfrom()"); |
|
102 | } | |
|
106 | }else | |
|
107 | printf("Recibidos: %i\n",numbytes_recibidos); | |
|
103 | 108 | |
|
104 | 109 | /* Se procede a procesar los datos recibidos */ |
|
105 | 110 | buff_peticion[numbytes_recibidos]= '\0'; |
|
111 | printf("%s\n",buff_peticion); | |
|
106 | 112 | |
|
107 | 113 | /* procesamiento de la peticion */ |
|
108 | rpta = procesa_peticion(buff_peticion); | |
|
114 | //rpta = procesa_peticion(buff_peticion); | |
|
115 | procesa_peticion(buff_peticion); | |
|
109 | 116 | |
|
110 | 117 | //Respuesta del modulo de control |
|
111 | 118 | // |
@@ -141,29 +148,35 | |||
|
141 | 148 | /* |
|
142 | 149 | * Esta funcion procesa el mensaje de peticion y genera respuesta |
|
143 | 150 | */ |
|
144 | int procesa_peticion(char *buff_peticion){ | |
|
145 | int rpta; | |
|
151 | //int procesa_peticion(char *buff_peticion){ | |
|
152 | void procesa_peticion(char *buff_peticion){ | |
|
153 | //int rpta = 0; | |
|
154 | ||
|
146 | 155 | // char *header = strtok(buff_peticion, ":"); |
|
147 | 156 | // char *ipSource = strtok(buff_peticion, ":"); |
|
148 | 157 | // char *ipDestino = strtok(buff_peticion, ":"); |
|
149 | 158 | char *comando = strtok(buff_peticion, ":"); |
|
150 | 159 | char *valor = strtok(NULL, ":"); |
|
151 | 160 | |
|
161 | printf("Testpoint_1\n"); | |
|
152 | 162 | if ((comando == NULL) || (valor == NULL)){ |
|
153 | 163 | ERROR("procesarPeticion: formato de mensaje incorrecto"); |
|
154 | 164 | } |
|
155 | 165 | else{ |
|
156 | 166 | if(strcmp(comando,"CARGA") == 0) |
|
157 | rpta = carga_experimento(valor); | |
|
167 | //rpta = carga_experimento(valor); | |
|
168 | carga_experimento(valor); | |
|
158 | 169 | else if(strcmp(comando,"CAMBIA") == 0) |
|
159 | rpta = cambia_apuntamiento(valor); | |
|
170 | //rpta = cambia_apuntamiento(valor); | |
|
171 | cambia_apuntamiento(valor); | |
|
160 | 172 | else if(strcmp(comando,"CHEQUEO") == 0) |
|
161 | rpta = chequeo_sistema(valor); | |
|
173 | //rpta = chequeo_sistema(valor); | |
|
174 | chequeo_sistema(valor); | |
|
162 | 175 | else |
|
163 | 176 | ERROR("procesa_peticion: comando no reconocido"); |
|
164 | 177 | } |
|
165 | 178 | |
|
166 | return rpta; | |
|
179 | //return rpta; | |
|
167 | 180 | } |
|
168 | 181 | |
|
169 | 182 | |
@@ -172,7 +185,8 | |||
|
172 | 185 | * este buffer es usado en la funcion "cambia_apuntamiento" para obtener el dato |
|
173 | 186 | * que sera usado en el cambio de apuntamiento. |
|
174 | 187 | */ |
|
175 | int carga_experimento(char *nombre_archivo){ | |
|
188 | //int carga_experimento(char *nombre_archivo){ | |
|
189 | void carga_experimento(char *nombre_archivo){ | |
|
176 | 190 | |
|
177 | 191 | FILE *Archivo_Fd; |
|
178 | 192 | |
@@ -189,9 +203,9 | |||
|
189 | 203 | Archivo_Fd = fopen(ruta_archivo,"r"); // Se procede a abrir el archivo, segun la ruta especificada |
|
190 | 204 | if(!Archivo_Fd){ |
|
191 | 205 | ERROR("carga_archivo: No se pudo abrir el archivo!!! --> fopen()\n"); |
|
192 | return -1; | |
|
206 | // return -1; | |
|
193 | 207 | }else{ |
|
194 | ||
|
208 | printf("Testpoint_2\n"); | |
|
195 | 209 | while(!feof(Archivo_Fd)){ // Se procede a calcular la longitud del archivo para separar memoria |
|
196 | 210 | fgets(cadena,20,Archivo_Fd); |
|
197 | 211 | longitud_cadena= strlen(cadena); |
@@ -206,7 +220,8 | |||
|
206 | 220 | // la longitud del archivo |
|
207 | 221 | fread(buffer_temporal, sizeof(char), num_bytes, Archivo_Fd); |
|
208 | 222 | |
|
209 | char *puntero= strstr(buffer_temporal,".abs"); // Se procede a eliminar la cabecera del archivo | |
|
223 | printf("Testpoint_3\n"); | |
|
224 | char *puntero= strstr(buffer_temporal,".ab1"); // Se procede a eliminar la cabecera del archivo | |
|
210 | 225 | puntero= puntero + 12; |
|
211 | 226 | |
|
212 | 227 | buff_experimento = (char *) malloc(7*(num_filas-3)); // num_bytes_fila*(num_filas-3); |
@@ -214,9 +229,9 | |||
|
214 | 229 | |
|
215 | 230 | fclose(Archivo_Fd); |
|
216 | 231 | |
|
217 | cambia_apuntamiento("0"); // Se apunta a la direccion 0 | |
|
218 | ||
|
219 | return 1; | |
|
232 | //cambia_apuntamiento("0"); // Se apunta a la direccion 0 | |
|
233 | ||
|
234 | // return 1; | |
|
220 | 235 | } |
|
221 | 236 | } |
|
222 | 237 | |
@@ -226,7 +241,8 | |||
|
226 | 241 | * dato es el valor que se enviara al sistema de conmutacion RF para el cambio de apunte a |
|
227 | 242 | * traves del puerto GPIO. |
|
228 | 243 | */ |
|
229 | int cambia_apuntamiento(char *puntero_char){ | |
|
244 | //int cambia_apuntamiento(char *puntero_char){ | |
|
245 | void cambia_apuntamiento(char *puntero_char){ | |
|
230 | 246 | |
|
231 | 247 | /*MSB-UP-LSB MSB-DOWN-LSB*/ |
|
232 | 248 | int desplazamiento[6]={30,28,26,24,22,20}; // Defino los dezplazamientos que se aplicara |
@@ -265,7 +281,7 | |||
|
265 | 281 | pio_out(pioc, maskc_out, acumulado_unos, 1); |
|
266 | 282 | pio_out(pioc, maskc_out, acumulado_ceros, 0); |
|
267 | 283 | |
|
268 | return 1; | |
|
284 | //return 1; | |
|
269 | 285 | |
|
270 | 286 | } |
|
271 | 287 | |
@@ -274,7 +290,8 | |||
|
274 | 290 | * archivo Verificacion. |
|
275 | 291 | */ |
|
276 | 292 | |
|
277 | int chequeo_sistema(char *numero_muestras){ | |
|
293 | //int chequeo_sistema(char *numero_muestras){ | |
|
294 | void chequeo_sistema(char *numero_muestras){ | |
|
278 | 295 | |
|
279 | 296 | char valor[7]; |
|
280 | 297 | int i,cnt; |
@@ -314,9 +331,9 | |||
|
314 | 331 | cnt=cnt+1; |
|
315 | 332 | usleep(1*1000*1000); |
|
316 | 333 | |
|
317 | }while(cnt < atoi(numero_muestras)); | |
|
334 | }while(cnt < (atoi(numero_muestras)+1)); | |
|
318 | 335 | |
|
319 | 336 | fclose(fd); |
|
320 | 337 | |
|
321 | return 1; | |
|
322 | } | |
|
338 | //return 1; | |
|
339 | } |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now