Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BufferedSerial PinDetect mbed
Fork of DTK-MEGAPACA_NUCLEO by
funciones_basicas.h
00001 /* 00002 * - Proyecto: Apagado Temporizado MEGAPACA 00003 * - Lenguaje: ANSI C/C++ (mbed) 00004 * - Tarjeta: NUCLEO F303K8 00005 * - Referencias: 00006 * - Fecha: 2017/Septiembre 00007 * - Autor(es): Felícito Manzano / 00008 Mario Vargas 00009 * - Compañia: V.S.R. de Centroamérica 00010 * - País: SV / CR 00011 */ 00012 00013 #include "constantes.hpp" 00014 #include "BufferedSerial.h" 00015 00016 int incrementar_trama(int *tramas) 00017 { 00018 /* 00019 Esta función recibe un entero que es el contador de tramas 00020 realiza el incremento en uno y verifica si el valor es mayor 00021 o igual que 65535 que es equivalente a 0xFFFF. Si se cumple 00022 la condución se regresa el valor a 1. 00023 Esta función siempre retorna 0. 00024 */ 00025 int actual = *tramas; 00026 int limite = 65535; 00027 actual++; 00028 00029 if (actual > limite) { 00030 *tramas = 1; 00031 } else { 00032 *tramas = actual; 00033 } 00034 return(0); 00035 } 00036 00037 int iniciando(BufferedSerial *puerto_cp) 00038 { 00039 /* 00040 Esta función recibe los puertos Seriales del GV300 y de la PC 00041 conectada por USB para notificar que se ha reiniciado la interfaz. 00042 Siempre retorna 0 00043 */ 00044 puerto_cp -> printf("%s\r\n", RESET_TXT); 00045 wait_ms(T_TX); 00046 return(0); 00047 } 00048 00049 bool leer_uart(BufferedSerial *puerto, char buffer[128]) 00050 { 00051 /* Esta función se encarga de leer el puerto serial y 00052 almacenar la respuesta en un buffer de datos de entrada. 00053 Si se lee información, la función devuelve 1, sino 0. */ 00054 00055 bool x = false; 00056 int w = 0; 00057 00058 00059 if (puerto -> readable()) { 00060 x = true; 00061 while (puerto -> readable()) { 00062 char incoming_char = puerto -> getc(); 00063 buffer[w] = incoming_char; 00064 w++; 00065 } 00066 buffer[w] = '\0'; 00067 } 00068 return(x); 00069 } 00070 00071 int procesar_trama(char buffer[128]) 00072 { 00073 /* Esta función se encarga de verificar que se ha recibido una trama desde Skytrack 00074 o si el comando de apagado se ejecutó apropiadamente. */ 00075 00076 int x = 0; 00077 00078 if (strstr(buffer, ABORT_TXT) != NULL) { 00079 x = 1; // Se recibió trama con "ABORTAR" 00080 } 00081 00082 if (strstr(buffer, GTOUT_TXT) != NULL) { 00083 x = 2; // Se recibió trama con "ACK:GTOUT" 00084 } 00085 00086 if (strstr(buffer, GV300_OK) != NULL) { 00087 x = 3; // El GV300 se la pasa mandando OK 00088 } 00089 00090 return(x); 00091 }
Generated on Tue Jul 19 2022 21:23:56 by
