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.
Revision 1:c7bcbf5eac28, committed 2021-05-24
- Comitter:
- fmanzano_dtk
- Date:
- Mon May 24 01:42:28 2021 -0600
- Parent:
- 0:3f87407d8640
- Child:
- 2:ec0ddc911bd1
- Commit message:
- Actualizacion general de codigo. Version no compilable.
Changed in this revision
--- a/README.md Mon May 24 04:20:16 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ - -# Blinky Mbed OS example - -The example project is part of the [Arm Mbed OS Official Examples](https://os.mbed.com/code/) and is the [getting started example for Mbed OS](https://os.mbed.com/docs/mbed-os/v5.14/quick-start/index.html). It contains an application that repeatedly blinks an LED on supported [Mbed boards](https://os.mbed.com/platforms/). - -You can build the project with all supported [Mbed OS build tools](https://os.mbed.com/docs/mbed-os/latest/tools/index.html). However, this example project specifically refers to the command-line interface tool [Arm Mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). -(Note: To see a rendered example you can import into the Arm Online Compiler, please see our [import quick start](https://os.mbed.com/docs/mbed-os/latest/quick-start/online-with-the-online-compiler.html#importing-the-code).) - -1. [Install Mbed CLI](https://os.mbed.com/docs/mbed-os/latest/quick-start/offline-with-mbed-cli.html). - -1. Clone this repository on your system, and change the current directory to where the project was cloned: - - ```bash - $ git clone git@github.com:armmbed/mbed-os-example-blinky && cd mbed-os-example-blinky - ``` - - Alternatively, you can download the example project with Arm Mbed CLI using the `import` subcommand: - - ```bash - $ mbed import mbed-os-example-blinky && cd mbed-os-example-blinky - ``` - - -## Application functionality - -The `main()` function is the single thread in the application. It toggles the state of a digital output connected to an LED on the board. - -## Building and running - -1. Connect a USB cable between the USB port on the board and the host computer. -2. <a name="build_cmd"></a> Run the following command to build the example project and program the microcontroller flash memory: - ```bash - $ mbed compile -m <TARGET> -t <TOOLCHAIN> --flash - ``` -The binary is located at `./BUILD/<TARGET>/<TOOLCHAIN>/mbed-os-example-blinky.bin`. - -Alternatively, you can manually copy the binary to the board, which you mount on the host computer over USB. - -Depending on the target, you can build the example project with the `GCC_ARM`, `ARM` or `IAR` toolchain. After installing Arm Mbed CLI, run the command below to determine which toolchain supports your target: - -```bash -$ mbed compile -S -``` - -## Expected output -The LED on your target turns on and off every 500 milliseconds. - - -## Troubleshooting -If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it. - -## Related Links - -* [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html). -* [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html). -* [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html). -* [Mbed OS bare metal](https://os.mbed.com/docs/mbed-os/latest/reference/mbed-os-bare-metal.html). -* [Mbed boards](https://os.mbed.com/platforms/). - -### License and contributions - -The software is provided under Apache-2.0 license. Contributions to this project are accepted under the same license. Please see contributing.md for more info. - -This project contains code from other projects. The original license text is included in those source files. They must comply with our license guide.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/constantes.cpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,127 @@ +/** + * @file constantes.cpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ + + +#include "constantes.hpp" + +/* DIRECCIÓN DE BAHÍA */ +#define BAY_NUMBER 4 + +#if (BAY_NUMBER == 1) + const char ALIVE[] = "Bahia 1-OK"; //"@BAY1-OK#"; + const char BAY_RESET[] = "Bahia 1-Reinicio"; //"@BAY1-REBOOT#" + const char BAY_EMPTY[] = "Bahia 1-Vacia"; //"@BAY1-EMPTY#"; + const char BAY_NEWID[] = "Bahia 1-TAG:"; //"@BAY1-ID:"; + const char BAY_LIDAR[] = "Bahia 1-LiDAR Error"; +#elif (BAY_NUMBER == 2) + const char ALIVE[] = "Bahia 2-OK"; //"@BAY1-OK#"; + const char BAY_RESET[] = "Bahia 2-Reinicio"; //"@BAY1-REBOOT#" + const char BAY_EMPTY[] = "Bahia 2-Vacia"; //"@BAY1-EMPTY#"; + const char BAY_NEWID[] = "Bahia 2-TAG:"; //"@BAY1-ID:"; + const char BAY_LIDAR[] = "Bahia 2-LiDAR Error"; +#elif (BAY_NUMBER == 3) + const char ALIVE[] = "Bahia 3-OK"; //"@BAY1-OK#"; + const char BAY_RESET[] = "Bahia 3-Reinicio"; //"@BAY1-REBOOT#" + const char BAY_EMPTY[] = "Bahia 3-Vacia"; //"@BAY1-EMPTY#"; + const char BAY_NEWID[] = "Bahia 3-TAG:"; //"@BAY1-ID:"; + const char BAY_LIDAR[] = "Bahia 3-LiDAR Error"; +#elif (BAY_NUMBER == 4) + const char ALIVE[] = "Bahia 4-OK"; //"@BAY1-OK#"; + const char BAY_RESET[] = "Bahia 4-Reinicio"; //"@BAY1-REBOOT#" + const char BAY_EMPTY[] = "Bahia 4-Vacia"; //"@BAY1-EMPTY#"; + const char BAY_NEWID[] = "Bahia 4-TAG:"; //"@BAY1-ID:"; + const char BAY_LIDAR[] = "Bahia 4-LiDAR Error"; +#else + const char ALIVE[] = "Bahia 5-OK"; //"@BAY1-OK#"; + const char BAY_RESET[] = "Bahia 5-Reinicio"; //"@BAY1-REBOOT#" + const char BAY_EMPTY[] = "Bahia 5-Vacia"; //"@BAY1-EMPTY#"; + const char BAY_NEWID[] = "Bahia 5-TAG:"; //"@BAY1-ID:"; + const char BAY_LIDAR[] = "Bahia 5-LiDAR Error"; +#endif + +/* DEFINICIÓN DE CONSTANTES PARA GV300 */ +const char CABECERA_TX[] = "AT+GTDAT=gv300,2,,"; +const char CODIGO_INT[] = "TCA|505|"; +const char FIN_CABECERA_TX[] = ",0,,,,"; +const char ULTIMO_CARACTER[] = "$"; +const char SEPARADOR[] = ";"; + +// CONSTANTES DE PUERTO SERIAL +const int BUFF_SIZE = 498; +const int TX_MULTIP = 1; + +// OTRAS CONSTANTES +const int T_ESPERA_CP = 300000; // micro segundos +const int T_TX = 10000; // micro segundos +const int DECLARAR_VACIO = 3600; // Segundos para declarar que la bahía está vacia +const int DELTA_ID = 15; +const int MAX_REINTENTOS = 4; +const int MINUTO = 60; // Un minuto = 60 segundos +const int TIEMPO_RECARGA = 7200; // dos horas = 7200 +const int LIMPIA = 10800; // Tres horas = 10800 segundos +const float TIME_HEARTBEAT = 1800.0; + +// DEFINICIÓN PARA DISPLAY DE 7 SEGMENTOS +// DEFINICIÓN PARA ANODO COMÚN +/* +const int DIGITOS[11] = { // G, F, E, D, C, B, A --> Invertido para BusOut + 0x40, // CERO (1000000) + 0x79, // UNO (1111001) + 0x24, // DOS (0100100) + 0x30, // TRES (0110000) + 0x19, // CUATRO (0011001) + 0x12, // CINCO (0010010) + 0x02, // SEIS (0000010) + 0x78, // SIETE (1111000) + 0x00, // OCHO (0000000) + 0x10, // NUEVE (0010000) + 0x7F // APAGADO CON 10 (1111111) + }; + */ + +// CATODO COMÚN +const int DIGITOS[11] = { // G, F, E, D, C, B, A --> Invertido para BusOut + 0x3F, // {0111111}, // CERO + 0x06, // {0000110}, // UNO + 0x5B, // {1011011}, // DOS + 0x4F, // {1001111}, // TRES + 0x66, // {1100110}, // CUATRO + 0x6D, // {1101101}, // CINCO + 0x7D, // {1111101}, // SEIS + 0x07, // {0000111}, // SIETE + 0x7F, // {1111111}, // OCHO + 0x6F, // {1101111}, // NUEVE + 0x00 // {00000000} // APAGADO CON 10 + }; + + +const int COLOR_TORRE_LUZ[4] = { // ROJO, AMARILLO, VERDE --> Invertido para BusOut + 0x00, // {0, 0, 0}, // APAGADO CON 0 + 0x01, // {0, 0, 1}, // VERDE + 0x02, // {0, 1, 0}, // AMARILLLO + 0x04 // {1, 0, 0} // ROJO + }; + +const int APAGADO_TL = 0; +const int VERDE = 1; +const int AMARILLO = 2; +const int ROJO = 3; +const int CERO_7S = 0; +const int UNO_7S = 1; +const int DOS_7S = 2; +const int TRES_7S = 3; +const int CUATRO_7S = 4; +const int CINCO_7S = 5; +const int SEIS_7S = 6; +const int SIETE_7S = 7; +const int OCHO_7S = 8; +const int NUEVE_7S = 9; +const int APAGADO_7S = 10; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/constantes.hpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,67 @@ +/** + * @file constantes.hpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ + + + +#ifndef __CONSTANTES_HPP +#define __CONSTANTES_HPP + + + /* DIRECCIÓN DE BAHÍA */ + extern const int BAY_ADDRESS; + extern const char BAY_RESET[19]; + extern const char BAY_EMPTY[16]; + extern const char BAY_NEWID[14]; + extern const char BAY_LIDAR[22]; + + /* DEFINICIÓN DE CONSTANTES PARA GV300 */ + extern const char CABECERA_TX[19]; + extern const char CODIGO_INT[9]; + extern const char FIN_CABECERA_TX[7]; + extern const char ULTIMO_CARACTER[2]; + extern const char SEPARADOR[2]; + + // CONSTANTES DE PUERTO SERIAL + extern const int BUFF_SIZE; + extern const int TX_MULTIP; + + // OTRAS CONSTANTES + extern const int T_ESPERA_CP; // mili segundos + extern const int T_TX; // mili segundos + extern const int DECLARAR_VACIO; + extern const int DELTA_ID; + extern const int MINUTO; + extern const int TIEMPO_RECARGA; + extern const int LIMPIA; + extern const float TIME_HEARTBEAT; + extern const char ALIVE[11]; + extern const int MAX_REINTENTOS; + + // DEFINICIÓN PARA DISPLAY DE 7 SEGMENTOS + extern const int DIGITOS[11]; + extern const int COLOR_TORRE_LUZ[4]; + extern const int APAGADO_TL; + extern const int VERDE; + extern const int AMARILLO; + extern const int ROJO; + extern const int CERO_7S; + extern const int UNO_7S; + extern const int DOS_7S; + extern const int TRES_7S; + extern const int CUATRO_7S; + extern const int CINCO_7S; + extern const int SEIS_7S; + extern const int SIETE_7S; + extern const int OCHO_7S; + extern const int NUEVE_7S; + extern const int APAGADO_7S; + +#endif // __CONSTANTES_HPP \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exe_lidar.cpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,95 @@ +/** + * @file exe_lidar.cpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-24 + * + * @copyright Copyright (c) 2021 + * + */ + +#include "mbed.h" +#include "BufferedSerial.h" +#include "constantes.hpp" + +extern BufferedSerial lidar; +extern DigitalOut display_DP; +extern bool lidar_respuesta; +extern bool lidar_valido; +extern bool mostrar_tiempo; +extern char skytrack_frame[]; +extern char lidar_rx_frame; +extern char actual_trailerID_HEX; +extern int lidar_contador_no_ack; +extern int distancia; +extern int lidar_vacio; +extern int contador_diferentes; +extern int contador_tramas; + +void exe_RFiD() { + lidar.write(TFMINIPLUS_TRIGGER_EXT,4); + wait_ms(50); + lidar_respuesta = leer_lidar(&lidar, lidar_rx_frame); + if (lidar_respuesta > 0) { + lidar_valido = parsear_lidar(lidar_rx_frame, &distancia); + if (mostrar_tiempo) { + //lidar.write(LIDAR_EXTERNAL_TRIGGER, 8); + lidar_contador_no_ack = 0; + if (lidar_valido) { + pcusb.printf("\r\nDistancia: %5d cm", distancia); + if (distancia>=DISTANCIA_VACIO) { + lidar_vacio++; + } else { + lidar_vacio = 0; + } + } else { // Respuesta invalida + pcusb.printf("\r\nLiDAR invalida:\r\n"); + for (w=0;w<lidar_respuesta;w++) { + printf("0x%02X ", lidar_rx_frame[w]); + } + pcusb.printf("\r\n"); + lidar_vacio++; + } + } else { // Sin respuesta de LiDAR. Notificar daño + lidar_vacio++; + lidar_contador_no_ack++; + //pcusb.printf("\r\nLiDAR no responde %d/%d", lidar_contador_no_ack, LIDAR_ERROR); + + // Notificar a plataforma que el LiDar lleva mucho tiempo sin responder. + if (lidar_contador_no_ack >= LIDAR_ERROR) { + pcusb.printf("\r\n%s",BAY_LIDAR); // Notificación + sprintf(skytrack_frame, "%s%s%s%s%04X%s", + CABECERA_TX,CODIGO_INT,BAY_LIDAR,FIN_CABECERA_TX,contador_tramas,ULTIMO_CARACTER); + gv300.printf("%s\r\n", skytrack_frame); + incrementar_trama(&contador_tramas); + lidar_contador_no_ack = 0; + } + } + + if (lidar_vacio == DECLARAR_LIDAR_VACIO) { + pcusb.printf("\r\nBahia vacia..."); // Notificación + contador_diferentes = 0; // Se reinicia el contador de diferentes + mostrar_tiempo = false; + + pcusb.printf("\r\nSemaforo APAGADO..."); + presentar_torre(&APAGADO_TL, &torreLuz); // Apagar torre de luz + display_DP = 0; + + pcusb.printf("\r\nCronometro a APAGADO..."); + display_uM.write(DIGITOS[APAGADO_7S]); // Apagar display de unidades de minuto + display_dM.write(DIGITOS[APAGADO_7S]); // Apagar display de decenas de minuto + display_H.write(DIGITOS[APAGADO_7S]); // Apagar display de horas + + sprintf(skytrack_frame, "%s%s%s%s%04X%s", + CABECERA_TX,CODIGO_INT,BAY_EMPTY,FIN_CABECERA_TX,contador_tramas,ULTIMO_CARACTER); + gv300.printf("%s\r\n", skytrack_frame); + incrementar_trama(&contador_tramas); + t_apagado.reset(); t_apagado.start(); // Se inicia un contador para saber cuanto tiempo ha estado apagado. + pcusb.printf("\r\nInicia margen de %d segundos para descartar TAG previo...", TIEMPO_RECARGA); + pcusb.printf("\r\nPrevio: %s\r\n\r\n", actual_trailerID_HEX); + } + } else { + flush_uart_rx(&lidar); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exe_lidar.hpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,19 @@ +/** + * @file exe_lidar.hpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ + + +#ifndef __EXE_LIDAR_HPP +#define __EXE_LIDAR_HPP + + void exe_RFiD(); + + +#endif // __EXE_LIDAR_HPP \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exe_rfid.cpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,125 @@ +/** + * @file exe_rfid.cpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ + + +#include "exe_rfid.hpp" +#include "constantes.hpp" +#include "BufferedSerial.h" +#include "f_basicas.hpp" + + +int leer_rfid(BufferedSerial *puerto_data, char id[256]) +{ + /* Esta función se encarga de leer el puerto serial y + almacenar la respuesta en un buffer de datos de entrada. + Esta función retorna la cantidad de caracteres leidos*/ + int i = 0; + + while (puerto_data -> readable()) {// || (i < 19)) { + int incoming_char = puerto_data -> getc(); + id[i] = incoming_char; + i++; + } + id[i] = '\0'; //strcpy(id, tmp_buff); + + return(i); +} + + +extern BufferedSerial rfid; +extern DigitalOut display_DP; +extern BusOut display_H; +extern BusOut display_dM; +extern BusOut display_uM; +extern Serial pcsusb; +extern Ticker ticker_minuto; +extern Timer t_apagado; +extern bool mostrar_tiempo; +extern char buffer_antena_ID[]; +extern char antena_trailerID_HEX[]; +extern char actual_trailerID_HEX[]; +extern char skytrack_frame[]; +extern int rfid_respuesta; +extern int bahia_vacia; +extern int lidar_vacio; +extern int comparacion; +extern int contador_diferentes; +extern int contador_tramas; +extern int horas; +extern int dminutos; +extern int uminutos; +extern int tiempo_luz_amarilla; +extern int tiempo_luz_roja; + +void exe_RFiD() { + rfid_respuesta = leer_rfid(&rf_id, buffer_antena_ID); + if (rfid_respuesta == 0) { // En caso que no se recibe información + bahia_vacia++; + if (bahia_vacia == DECLARAR_VACIO) { // Si ha pasado tiempo sin recibir datos de la antena RFiD + bahia_vacia = 0; // Para dar más tiempo a que responda la antena. + } + } else if ((rfid_respuesta > 16) && (rfid_respuesta <= 20)) { // En caso se recibió información del lector RFiD + bahia_vacia = lidar_vacio = 0; // Reiniciar el contador de vacio + convertir_id(buffer_antena_ID, antena_trailerID_HEX, &rfid_respuesta); + pcusb.printf("\r\nRFiD[%d]: %s", rfid_respuesta, antena_trailerID_HEX); + + comparacion = strcmp(actual_trailerID_HEX, antena_trailerID_HEX); + if (comparacion == 0) { // Comparar si se ha recuperado el anterior + if (!mostrar_tiempo) { + mostrar_tiempo = true; + pcusb.printf("\r\nReanudar conteo previo..."); + t_apagado.stop(); + t_apagado.reset(); + display_DP = 1; + presentar_torre(&VERDE, &torreLuz); // Cambiar a luz verde + presentar_tiempo(&horas, &dminutos, &uminutos, &display_H, &display_dM, &display_uM); // Configurar a 0 el cronometro + } + contador_diferentes = 0; + } else { // Comparar si es un nuevo cabezal + contador_diferentes++; // Incrementar contador de diferentes + pcusb.printf("\r\nDiferentes: %d", contador_diferentes); + + if (contador_diferentes == DELTA_ID) { + pcusb.printf("\r\nNuevo ID de cabezal...\r\n"); + mostrar_tiempo = true; + ticker_minuto.detach(); + t_ocupado.reset(); t_ocupado.start(); + t_apagado.stop(); + ticker_minuto.attach(&actualizar_minuto, 60.0); + horas = dminutos = uminutos = 0; // Reset las variables del cronometro + strcpy(actual_trailerID_HEX, antena_trailerID_HEX); + presentar_torre(&VERDE, &torreLuz); // Cambiar a luz verde + presentar_tiempo(&horas, &dminutos, &uminutos, &display_H, &display_dM, &display_uM); // Configurar a 0 el cronometro + display_DP = 1; + contador_diferentes = 0; + + pcusb.printf("\r\nSemaforo VERDE..."); + pcusb.printf("\r\nTiempo inicia en [0:00]"); + w = tiempo_asignado(actual_trailerID_HEX, &tiempo_luz_amarilla, &tiempo_luz_roja); // Cargar los tiempos de la torre de luz + if (w == 0) { + pcusb.printf("\r\nSin tiempo predeterminado\r\n\r\n"); + } else { + pcusb.printf("\r\nSemaforo - Amarillo:%d Rojo:%d\r\n\r\n", tiempo_luz_amarilla, tiempo_luz_roja); + } + + memset(skytrack_frame, '\0', sizeof skytrack_frame); // Limpiar última trama + sprintf(skytrack_frame, "%s%s%s%s%s%04X%s", + CABECERA_TX, CODIGO_INT, BAY_NEWID, actual_trailerID_HEX, FIN_CABECERA_TX, contador_tramas, ULTIMO_CARACTER); + gv300.printf("%s\r\n", skytrack_frame); + wait_ms(300); + } + } + } else { + bahia_vacia = lidar_vacio = 0; + pcusb.printf("\r\nDescartados %d", rfid_respuesta); + memset(antena_trailerID_HEX, '\0', sizeof antena_trailerID_HEX); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exe_rfid.hpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,21 @@ +/** + * @file exe_rfid.hpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ + + + +#ifndef __EXE_RFID_HPP +#define __EXE_RFID_HPP + + + int leer_rfid(BufferedSerial *puerto_data, char id[256]) + void exe_RFiD(); + +#endif // __EXE_RFID_HPP \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/f_basicas.cpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,428 @@ +/** + * @file f_basicas.cpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ + +#include "mbed.h" +#include "f_basicas.hpp" +#include "constantes.hpp" +#include "tagid.hpp" +#include "BufferedSerial.h" + + +/** + * @brief + * Esta función recibe un entero que es el contador de tramas + realiza el incremento en uno y verifica si el valor es mayor + o igual que 65535 que es equivalente a 0xFFFF. Si se cumple + la condución se regresa el valor a 1. + Esta función siempre retorna 0. + * + * @param tramas + * @return true + * @return false + */ +bool incrementar_trama(int *tramas) +{ + + int actual = *tramas; + int limite = 65535; + actual++; + + if (actual > limite) { + *tramas = 1; + } else { + *tramas = actual; + } + return(false); +} + + + +/** + * @brief + * + * @param puerto_usb + * @param puerto_cp + * @return true + * @return false + */ +bool booting_gtdat(Serial *puerto_usb, Serial *puerto_cp) { + wait_us(1000000); + puerto_usb -> printf("\r\n*** DETEKTOR LATAM ***\r\n"); + puerto_usb -> printf("INICIANDO NUCLEO STM32\r\n"); + puerto_usb -> printf("CCN TIEMPO EN PLANTA\r\n"); + puerto_usb -> printf("R.0A.1 - 2021-05-24\r\n\r\n"); + puerto_usb -> printf("BAHIA-%d\r\n", BAY_ADDRESS); + puerto_cp -> printf("%s*INICIA BAHIA-%d*%s0001%s\r\n", + CABECERA_TX, BAY_ADDRESS, FIN_CABECERA_TX, ULTIMO_CARACTER); + wait_us(T_TX); + return(false); +} + + + +/** + * @brief + * + * Esta función recibe los digitos correspondientes a las horas, decenas y + minutos que representan la hora y que deben presentarse en los tres + display de siete segmentos. La función siempre retorna 0. + * @param horas + * @param decenas + * @param minutos + * @param d7_h + * @param d7_d + * @param d7_m + * @return int + */ +int presentar_tiempo(int *horas, int *decenas, int *minutos, + BusOut *d7_h, BusOut *d7_d, BusOut *d7_m) +{ + // Digito más significativo (HORAS) + switch (*horas) { + case 0 : + d7_h -> write(DIGITOS[CERO_7S]); + break; + case 1 : + d7_h -> write(DIGITOS[UNO_7S]); + break; + case 2 : + d7_h -> write(DIGITOS[DOS_7S]); + break; + case 3 : + d7_h -> write(DIGITOS[TRES_7S]); + break; + case 4 : + d7_h -> write(DIGITOS[CUATRO_7S]); + break; + case 5 : + d7_h -> write(DIGITOS[CINCO_7S]); + break; + case 6 : + d7_h -> write(DIGITOS[SEIS_7S]); + break; + case 7 : + d7_h -> write(DIGITOS[SIETE_7S]); + break; + case 8 : + d7_h -> write(DIGITOS[OCHO_7S]); + break; + case 9 : + d7_h -> write(DIGITOS[NUEVE_7S]); + break; + case 10: + d7_h -> write(DIGITOS[APAGADO_7S]); + break; + } + + // DECENAS DE MINUTOS + switch (*decenas) { + case 0 : + d7_d -> write(DIGITOS[CERO_7S]); + break; + case 1 : + d7_d -> write(DIGITOS[UNO_7S]); + break; + case 2 : + d7_d -> write(DIGITOS[DOS_7S]); + break; + case 3 : + d7_d -> write(DIGITOS[TRES_7S]); + break; + case 4 : + d7_d -> write(DIGITOS[CUATRO_7S]); + break; + case 5 : + d7_d -> write(DIGITOS[CINCO_7S]); + break; + case 6 : + d7_d -> write(DIGITOS[SEIS_7S]); + break; + case 7 : + d7_d -> write(DIGITOS[SIETE_7S]); + break; + case 8 : + d7_d -> write(DIGITOS[OCHO_7S]); + break; + case 9 : + d7_d -> write(DIGITOS[NUEVE_7S]); + break; + case 10: + d7_d -> write(DIGITOS[APAGADO_7S]); + break; + } + + // Digito menos significativo (MINUTOS ) + switch (*minutos) { + case 0 : + d7_m -> write(DIGITOS[CERO_7S]); + break; + case 1 : + d7_m -> write(DIGITOS[UNO_7S]); + break; + case 2 : + d7_m -> write(DIGITOS[DOS_7S]); + break; + case 3 : + d7_m -> write(DIGITOS[TRES_7S]); + break; + case 4 : + d7_m -> write(DIGITOS[CUATRO_7S]); + break; + case 5 : + d7_m -> write(DIGITOS[CINCO_7S]); + break; + case 6 : + d7_m -> write(DIGITOS[SEIS_7S]); + break; + case 7 : + d7_m -> write(DIGITOS[SIETE_7S]); + break; + case 8 : + d7_m -> write(DIGITOS[OCHO_7S]); + break; + case 9 : + d7_m -> write(DIGITOS[NUEVE_7S]); + break; + case 10: + d7_m -> write(DIGITOS[APAGADO_7S]); + break; + } + + return(0); +} + +int presentar_torre(const int *color, BusOut *torre_luz) +{ + /* + Esta función recibe el código de color correspondiente a la torre de luz + estilo semaforo para activar el LED correspondiente. + La función siempre retorna 0 + */ + + switch (*color) { + case 0 : + torre_luz -> write(COLOR_TORRE_LUZ[APAGADO_TL]); + break; + case 1 : + torre_luz -> write(COLOR_TORRE_LUZ[VERDE]); + break; + case 2 : + torre_luz -> write(COLOR_TORRE_LUZ[AMARILLO]); + break; + case 3 : + torre_luz -> write(COLOR_TORRE_LUZ[ROJO]); + break; + } + + return(0); +} + + + +/** + * @brief + * Esta función se encarga de buscar el grupo al que está asignado el TAGRFiD + que ha sido leido por el lector. Se ha predefinido 3 arreglos con los TAG + validos. En función del arreglo en que se genere la coincidencia se retorna + el tiempo para cambiar. + La función retorna 1 cuando encuentra coincidencia. 0 cuando no encuentra coincidencia y + se define el tiempo de la torre de luz amarillo y rojo en 50 minutos y 1 hora. + * + * @param id + * @param amarillo + * @param rojo + * @return int + */ +int tiempo_asignado(char id[9], int *amarillo, int *rojo) +{ + int i = 0; + int v = 0; + int busca_id = 0; + + for (i=0; i<TOTAL_PLACAS_A; i++) { + busca_id = strncmp(PLACAS_A[i], id, 10); + if (busca_id == 0) { + *amarillo = GRUPO_A_AMARILLO; + *rojo = GRUPO_A_ROJO; + v = 1; return(1); + } + } + + for (i=0; i<TOTAL_PLACAS_B; i++) { + busca_id = strncmp(PLACAS_B[i], id, 10); + if (busca_id == 0) { + *amarillo = GRUPO_B_AMARILLO; + *rojo = GRUPO_B_ROJO; + v = 1; return(1); + } + } + + for (i=0; i<TOTAL_PLACAS_C; i++) { + busca_id = strncmp(PLACAS_C[i], id, 10); + if (busca_id == 0) { + *amarillo = GRUPO_C_AMARILLO; + *rojo = GRUPO_C_ROJO; + v = 1; return(1); + } + } + + if (v) { + return(1); + } else { + *amarillo = GRUPO_DEFAULT_AMARILLO; + *rojo = GRUPO_DEFAULT_ROJO; + return(0); + } +} + + + +/** + * @brief + * + * Esta función se encarga de analisar el payload de una + huella que es enviada dentro de una cadena (char array) + expresada de manera hexadecimal. en su equivalente de código + ASCII que es guardado en otra cadena. + + * @param id_original + * @param id_hex + * @param tamano_id + * @return int + */ +int convertir_id(char id_original[256], char id_hex[15], int *tamano_id) +{ + int i = 0; + int j = 0; + int limite = *tamano_id; + int k = 0; + char tmp_buffer_ascii[77]; + + memset(tmp_buffer_ascii, '\0', sizeof tmp_buffer_ascii); + memset(id_hex, '\0', sizeof id_hex); + + for (i=0; i<limite; i++) { + snprintf(&tmp_buffer_ascii[j*2], 3,"%02X", id_original[i]); + j++; + } + + limite = strlen(tmp_buffer_ascii); + k = limite - 14; + + strncpy(id_hex, &tmp_buffer_ascii[k], 14); + id_hex[15] = '\0'; + + return(1); +} + + + +/** + * @brief + * Esta funsión se utiliza para limpiar el buffer de recepción del puerto seleccionado. + No se guarda ninguna información. Siempre devuelve true + * + * @param uart + * @return true + * @return false + */ +bool flush_uart_rx(BufferedSerial *uart) +{ + while (uart -> readable()) { + uart -> getc(); + } + return(true); +} + + + + + + +/** + * @brief + * + */ +extern Serial pcusb; +extern BusOut torreLuz; +extern BusOut display_H; +extern BusOut display_dM; +extern BusOut display_uM; +extern float tiempo_actual; +extern bool mostrar_tiempo; +extern char actual_trailerID_HEX[]; +extern char antena_trailerID_HEX[]; +extern int rtc_delta; +extern int uminutos; +extern int dminutos; +extern int horas; +extern int tiempo_luz_amarilla; +extern int tiempo_luz_roja + +void update_Display7s() { + // ACTUALIZACIÓN DE PANTALLA DE CRONOMETRO + uminutos++; // Acumular un minuto + if (uminutos >= 10) { // Si es 10 cambiar 0 + uminutos = 0; + dminutos++; // Acumularse las decenas de minutos + } + if (dminutos >= 6) { // Si es 6 cambiar 0 + dminutos = 0; // Acumular una hora + horas++; + } + + if (mostrar_tiempo) { + rtc_delta = (int)t_ocupado.read(); + pcusb.printf("\r\nTiempo total en Bahia: %d segundos", rtc_delta); + + if ((rtc_delta >= tiempo_luz_amarilla) && (rtc_delta < tiempo_luz_roja)) { // Si estamos en el rango de 50 - 59 minutos + pcusb.printf("\r\nSemaforo AMARILLO..."); + presentar_torre(&AMARILLO, &torreLuz); // Activar luz ambar + } else if (rtc_delta >= tiempo_luz_roja) { + pcusb.printf("\r\nSemaforo ROJO..."); + presentar_torre(&ROJO, &torreLuz); // Activar luz roja + } else { + presentar_torre(&VERDE, &torreLuz); // Activar luz ambar + } + presentar_tiempo(&horas, &dminutos, &uminutos, &display_H, &display_dM, &display_uM);// Actualizar la vista del cronometro + pcusb.printf("\r\nTiempo actual [H:MM] = %d:%d%d\r\n\r\n", horas, dminutos, uminutos); + } else { + tiempo_actual = t_apagado.read(); + if (tiempo_actual >= (TIEMPO_RECARGA)) { + pcusb.printf("\r\nSobrepasa limite de %d segundos con pantallas apagadas", TIEMPO_RECARGA); + pcusb.printf("\r\nSe descarta TAG actual y reinicia contadores.\r\n"); + ticker_minuto.detach(); + t_apagado.stop(); + memset(actual_trailerID_HEX, '\0', sizeof actual_trailerID_HEX); + memset(antena_trailerID_HEX, '\0', sizeof antena_trailerID_HEX); + } + } + + +} + + +/** + * @brief + * + */ +extern Serial gv300; +extern char skytrack_frame[]; +extern int contador_tramas; +void tx_skytrack() +{ + sprintf(skytrack_frame, "%s%s%s%s%04X%s", + CABECERA_TX,CODIGO_INT,ALIVE, FIN_CABECERA_TX, contador_tramas, ULTIMO_CARACTER); + gv300.printf("%s\r\n", skytrack_frame); + memset(skytrack_frame, '\0', sizeof(skytrack_frame)); // Vaciar el buffer de Skytrack Frame + incrementar_trama(&contador_tramas); + pcusb.printf("\r\n%s", ALIVE); +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/f_basicas.hpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,26 @@ +/** + * @file f_basicas.hpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ + + +#ifndef __FUNC_BASICAS_HPP +#define __FUNC_BASICAS_HPP + + bool incrementar_trama(int *tramas); + bool booting_gtdat(Serial *puerto_usb, Serial *puerto_cp); + int presentar_tiempo(int *horas, int *decenas, int *minutos, BusOut *d7_h, BusOut *d7_d, BusOut *d7_m); + int presentar_torre(const int *color, BusOut *torre_luz); + int tiempo_asignado(char id[9], int *amarillo, int *rojo); + int convertir_id(char id_original[256], char id_hex[15], int *tamano_id); + bool flush_uart_rx(BufferedSerial *uart); + void update_Display7s(); + void tx_skytrack(); + +#endif // __FUNC_BASICAS_HPP \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lidar_tfminiplus.cpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,78 @@ +/** + * @file lidar_tfminiplus.cpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ + +#include "lidar_tfminiplus.hpp" +#include "BufferedSerial.h" +#include "constantes.hpp" + + +// CONSTANTES LIDAR +const char LIDAR_EXTERNAL_TRIGGER[] = { 0x42, 0x57, 0x02, 0x00, 0x00, 0x00, 0x00, 0x41 }; +const char LIDAR_GI_CONFIGURATION[] = { 0x42, 0x57, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02 }; +const char LIDAR_GO_CONFIGURATION[] = { 0x42, 0x57, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02 }; +const char LIDAR_CHANGE_OUTPUT_1S[] = { 0x42, 0x57, 0x02, 0x00, 0xE8, 0x03, 0x00, 0x07 }; +const char LIDAR_SET_DISTANCE_500[] = { 0x42, 0x57, 0x02, 0x00, 0x00, 0x00, 0x03, 0x11 }; +const char LIDAR_SET_EXTERNAL_TRI[] = { 0x42, 0x57, 0x02, 0x00, 0x00, 0x00, 0x00, 0x40 }; +const char TFMINIPLUS_UPDATE_RATE[] = { 0x5A, 0x06, 0x03, 0x00, 0x00, 0x63}; +const char TFMINIPLUS_TRIGGER_EXT[] = { 0x5A, 0x04, 0x04, 0x62}; +const int LIDAR_BYTE0 = 0x59; +const int DISTANCIA_VACIO = 450; +const int DECLARAR_LIDAR_VACIO = 270; +const int LIDAR_ERROR = 900; + + +/** + * @brief + * Esta función recibe un puerto Buffered Serial de Lidar + también un char array para almacenar los datos recibidos + * @param puerto_lidar + * @param mybuffer + * @return true + * @return false + */ +int leer_lidar(BufferedSerial *puerto_lidar, char mybuffer[18]) { + int contador = 0; + while (puerto_lidar->readable()) { + char incoming_char = puerto_lidar->getc(); + mybuffer[contador] = incoming_char; + contador++; + } + + return(contador); +} + + + +/** + * @brief + * Esta función recibe un CHAR ARRAY y evalua si cumple + con el protocolo de comunicación de LIDAR + retorna el valor de distancia expresado en centímetros + * + * @param mybuffer + * @param lidar_dist + * @return true + * @return false + */ +bool parsear_lidar(char mybuffer[18], int *lidar_dist) { + bool x = false; + + if ((mybuffer[0] == LIDAR_BYTE0) and (mybuffer[1] == LIDAR_BYTE0)) { + x= true; + unsigned int t1 = mybuffer[2]; //Byte3 + unsigned int t2 = mybuffer[3]; //Byte4 + t2 <<= 8; + t2 += t1; + *lidar_dist = t2; + } + + return(x); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lidar_tfminiplus.hpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,35 @@ +/** + * @file lidar_tfminiplus.hpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ + + +#ifndef __LIDAR_TF_MINI_PLU_HPP +#define __LIDAR_TF_MINI_PLU_HPP + + // CONSTANTES LIDAR + extern const char LIDAR_EXTERNAL_TRIGGER[9]; + extern const char LIDAR_GI_CONFIGURATION[9]; + extern const char LIDAR_GO_CONFIGURATION[9]; + extern const char LIDAR_CHANGE_OUTPUT_1S[9]; + extern const char LIDAR_SET_DISTANCE_500[9]; + extern const char LIDAR_SET_EXTERNAL_TRI[9]; + extern const char TFMINIPLUS_UPDATE_RATE[7]; + extern const char TFMINIPLUS_TRIGGER_EXT[5]; + extern const int LIDAR_BYTE0; + extern const int DISTANCIA_VACIO; + extern const int DECLARAR_LIDAR_VACIO; + extern const int LIDAR_ERROR; + + int leer_lidar(BufferedSerial *puerto_lidar, char mybuffer[18]); + bool parsear_lidar(char mybuffer[18], int *lidar_dist); + + + +#endif // __LIDAR_TF_MINI_PLU_HPP \ No newline at end of file
--- a/main.cpp Mon May 24 04:20:16 2021 +0000 +++ b/main.cpp Mon May 24 01:42:28 2021 -0600 @@ -1,19 +1,170 @@ +/** + * @file main.cpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ -#include "mbed.h" -#include "platform/mbed_thread.h" +#include "mbed.h" +#include "stm32f0xx_hal_iwdg.h" +#include "BufferedSerial.h" +#include "myPinout.hpp" +#include "f_basicas.hpp" +#include "constantes.hpp" +#include "testing.hpp" +#include "tagid.hpp" +#include "lidar_tfminiplus.hpp" +#include "exe_lidar.hpp" +#include "exe_rfid.hpp" + +/** CONFIGURACIÓN DE INTERFACES ***************************************** */ +Serial pcusb(USBTX, USBRX); +Serial gv300(GV300_TX, GV300_RX); +BufferedSerial rf_id(LIDAR_TX, LIDAR_RX); +BufferedSerial lidar(RF_ID_TX, RF_ID_RX); +InterruptIn mybutton(USER_BUTTON); +DigitalOut myled(LED1); +BusOut display_H(A_HOUR, B_HOUR, C_HOUR, D_HOUR, E_HOUR, F_HOUR, G_HOUR); +BusOut display_dM(A_DECE, B_DECE, C_DECE, D_DECE, E_DECE, F_DECE, G_DECE); +BusOut display_uM(A_MINU, B_MINU, C_MINU, D_MINU, E_MINU, F_MINU, G_MINU); +DigitalOut display_DP(DP_HOUR); +BusOut torreLuz(SEMAFORO_V, SEMAFORO_A, SEMAFORO_R); +static IWDG_HandleTypeDef my_iwdg; // HAL BASED -// Blinking rate in milliseconds -#define BLINKING_RATE_MS 500 +/** BANDERAS/FLUJO DE CÓDIGO ***************************************** */ +bool queryLIDAR = false; +bool tx_heartbeatSKT = false; +bool add_a_minute = false; +bool do_test = false; + +/** VARIABLES ***************************************** */ +float tiempo_actual = 0.0; // Para almacenar el valor del temporizador +bool lidar_respuesta = false; // Para determinar si el LiDAR respondió al External Trigar +bool lidar_valido = false; // Para determinar si la respuesta LiDAR es valida +bool mostrar_tiempo = false; // Para determinar si se encienden o apagan los Display de 7s +char lidar_rx_frame[18]; // Para almacenar la trama de respuesta del LiDAR +char skytrack_frame[128]; // Para almacenar la trama a enviar a Skytrack +char buffer_antena_ID[256]; // Para almacenar el ID del cabezal ASCII-puro desde RFiD -19 +char actual_trailerID_HEX[15]; // Para almacenar el ID recibido del cabezal en formato HEX-ASCII -15 +char antena_trailerID_HEX[15]; // Para almacenar el ID del cabezal previo en formato HEX-ASCII +int previo_semaforo = 0; +int rfid_respuesta = 0; // Para almacenar los bytes recibidos de la antena RFiD +int tiempo_luz_amarilla = 0; // Tiempo para encender la luz amarilla +int tiempo_luz_roja = 0; // Tiempo para encender la luz roja +int horas = 0; // Acumulador de horas +int dminutos = 0; // Acumulador de decenas de minutos +int uminutos = 0; // Acumulador de unidades de minutos +int rtc_delta = 0; // Para hacer la comparación con los tiempos, y calcular el tiempo total en Bahia +int bahia_vacia = 0; // Contador para determinar cuando una bahía está vacía, según RFiD +int lidar_vacio = 0; // Contador para determinar cuando una bahía está vacía, según LiDAR +int lidar_contador_no_ack = 0; // Contador para determinar cuantas veces no ha respondido el LiDAR +int contador_diferentes = 0; // Para contar la cantidad de TAGiD Diferentes +int comparacion = 0; // Para comparar cadenas cuando es diferente el RFiD +int contador_tramas = 0; // Contador de tramas enviadas al CP +int distancia = 0; // Almacenar lectura de distancia por LiDAR +int w = 0; // Registro de trabajo de multiples usos + + +/** TICKER DE MBED ***************************************** */ +Timer t_apagado; +Timer t_ocupado; +Ticker ticker_funcionando; // Ticker para hacer titilar un led +Ticker ticker_heartbeat; // Ticker para transmitir a Skytrack +Ticker ticker_minuto; // Ticker para contar un minuto +Ticker ticker_query_LiDAR; // Ticker para Consultar LiDAR + + +/** FUNCIONES GENERALES ***************************************** */ +void funcionando() { + myled = !myled; +} + +void hearbeat_SKT() { + tx_heartbeatSKT = true; + +} + +void minute_passed() { + add_a_minute = true; +} + +void pressed() { + do_test = true; +} + +void do_querryLIDAR(){ + queryLIDAR = true; +} int main() { - // Initialise the digital pin LED1 as an output - DigitalOut led(LED1); + pcusb.baud(115200); // Configuracion de Baudrate para la interfaz serial para USB + gv300.baud(115200); // Configuración de Baudrate para el cp gv300 + rf_id.baud(115200); // Configuración de Baudrate para el lector RFiD + lidar.baud(115200); // Configuración de Baudrate para el LiDAR + + torreLuz.write(COLOR_TORRE_LUZ[APAGADO_TL]); // Apagar Torre de Luz + display_uM.write(DIGITOS[APAGADO_7S]); // Apagar display de unidades de minuto + display_dM.write(DIGITOS[APAGADO_7S]); // Apagar display de decenas de minuto + display_H.write(DIGITOS[APAGADO_7S]); // Apagar display de horas + + memset(antena_trailerID_HEX, '\0', sizeof antena_trailerID_HEX); + memset(actual_trailerID_HEX, '\0', sizeof actual_trailerID_HEX); + memset(buffer_antena_ID, '\0', sizeof buffer_antena_ID); + + mybutton.fall(&pressed); + ticker_funcionando.attach(&funcionando, 1.0); + ticker_heartbeat.attach(&tx_skytrack, TIME_HEARTBEAT); + booting_gtdat(&pcusb, &gv300); // Enviar notificación de inicio + lidar.write(TFMINIPLUS_UPDATE_RATE,6); + flush_uart_rx(&lidar); + + /** + * @brief INICIAR WATCHDOG + * Se crea una instancia para el Watchdog, se define el pre-escaler + * y el valor máximo en caso que no se actualice se genera el reinicio. + */ + my_iwdg.Instance = IWDG; + my_iwdg.Init.Prescaler = IWDG_PRESCALER_256; + my_iwdg.Init.Reload = 0x0FFF; + my_iwdg.Init.Window = IWDG_WINDOW_DISABLE; + HAL_IWDG_Init(&my_iwdg); + boot_message(); + while (true) { - led = !led; - thread_sleep_for(BLINKING_RATE_MS); + + if (do_test) { + do_test = false; + HAL_IWDG_Refresh(&my_iwdg); + test_display7s(); + HAL_IWDG_Refresh(&my_iwdg); + } + + if (add_a_minute) { + add_a_minute = false; + update_Display7s(); + } + + if (tx_heartbeatSKT) { + tx_heartbeatSKT = false; + + } + + if (queryLIDAR) { + queryLIDAR = false; + exe_LIDAR(); + } + + exe_RFiD(); + + //! Actualizar Watchdog + HAL_IWDG_Refresh(&my_iwdg); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/myPinout.cpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,14 @@ +/** + * @file myPinout.cpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ + +#include "constantes.hpp" +#include "myPinout.hpp" +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/myPinout.hpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,94 @@ +/** + * @file myPinout.hpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ + + +#ifndef __MY_PINOUT_HPP +#define __MY_PINOUT_HPP + + #define BAY_NUMBER 4 + + #if (BAY_NUMBER == 4) + // Digital Outputs para Digitos de 7 segmentos + #define A_HOUR PB_9 + #define B_HOUR PB_12 + #define C_HOUR PB_8 + #define D_HOUR PA_11 + #define E_HOUR PC_9 + #define F_HOUR PA_12 + #define G_HOUR PC_8 + #define A_DECE PB_10 + #define B_DECE PB_1 + #define C_DECE PA_8 + #define D_DECE PB_2 + #define E_DECE PA_9 + #define F_DECE PB_11 + #define G_DECE PC_7 + #define A_MINU PA_10 + #define B_MINU PB_13 + #define C_MINU PB_3 + #define D_MINU PB_14 + #define E_MINU PB_5 + #define F_MINU PB_15 + #define G_MINU PB_4 + #define DP_HOUR PC_6 + + // Digital Outputs para Semaforo + #define SEMAFORO_V PB_0 + #define SEMAFORO_A PA_4 + #define SEMAFORO_R PA_1 + + // UART + #define GV300_TX PC_0 + #define GV300_RX PC_1 + #define RF_ID_TX PB_6 // #define RF_ID_TX PC_4 + #define RF_ID_RX PB_7 // #define RF_ID_RX PC_5 + #define LIDAR_TX PC_4 // #define LIDAR_TX PB_6 + #define LIDAR_RX PC_5 // #define LIDAR_RX PB_7 + + #else + // Digital Outputs para Digitos de 7 segmentos + #define A_HOUR PB_9 + #define B_HOUR PB_12 + #define C_HOUR PB_8 + #define D_HOUR PA_11 + #define E_HOUR PC_9 + #define F_HOUR PA_12 + #define G_HOUR PC_8 + #define A_DECE PB_10 + #define B_DECE PB_1 + #define C_DECE PA_8 + #define D_DECE PB_2 + #define E_DECE PA_9 + #define F_DECE PB_11 + #define G_DECE PC_7 + #define A_MINU PA_10 + #define B_MINU PB_13 + #define C_MINU PB_3 + #define D_MINU PB_14 + #define E_MINU PB_5 + #define F_MINU PB_15 + #define G_MINU PB_4 + #define DP_HOUR PC_6 + + // Digital Outputs para Semaforo + #define SEMAFORO_V PB_0 + #define SEMAFORO_A PA_4 + #define SEMAFORO_R PA_1 + + // UART + #define GV300_TX PC_0 + #define GV300_RX PC_1 + #define RF_ID_TX PC_4 + #define RF_ID_RX PC_5 + #define LIDAR_TX PB_6 + #define LIDAR_RX PB_7 + #endif +#endif // __MY_PINOUT_HPP \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tagid.cpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,78 @@ +/** + * @file tagid.cpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ + + +#include "tagid.hpp" + +// ARCHIVO PARA DEFINIR TODOS LOS RFiD DE LOS CABEZALES Y TIEMPO ASOCIADO +const int TOTAL_PLACAS_A = 5; // 01:50:00 +const int TOTAL_PLACAS_B = 12; // 01:20:00 +const int TOTAL_PLACAS_C = 24; // 01:30:00 + +const int GRUPO_A_AMARILLO = 3301; +const int GRUPO_B_AMARILLO = 2401; +const int GRUPO_C_AMARILLO = 2701; +const int GRUPO_DEFAULT_AMARILLO = 2701; +const int GRUPO_A_ROJO = 6601; +const int GRUPO_B_ROJO = 4801; +const int GRUPO_C_ROJO = 5401; +const int GRUPO_DEFAULT_ROJO = 5401; + +// char [TOTAL_ID_GRUPO] [TAMAÑO_ID] +char PLACAS_A[TOTAL_PLACAS_A][15] = { + {"202570110F2A97"}, + {"6625900FDAC6E2"}, + {"87257010D6DB13"}, + {"902590100A2C86"}, + {"98257010E0D299"} +}; + +char PLACAS_B[TOTAL_PLACAS_B][15] = { + {"09257011058509"}, + {"08257010FDDE60"}, + {"10257010FE25BC"}, + {"2125701117A700"}, + {"73257010B7E2D3"}, + {"74257010B08197"}, + {"7625900FEB8C76"}, + {"84257010CD45A0"}, + {"8425801241A551"}, + {"85257010D5C837"}, + {"8725901004CEEB"}, + {"9425801252FFC7"} +}; + +char PLACAS_C[TOTAL_PLACAS_C][15] = { + {"27257010586994"}, + {"002590101B1ABD"}, + {"0625801264AAB7"}, + {"07258012690B67"}, + {"22258011C2021C"}, + {"32258011D34AA9"}, + {"33258011CC784A"}, + {"382570106E601E"}, + {"43258011E92429"}, + {"46258011F222A1"}, + {"56258012030CD9"}, + {"57258011FC58F7"}, + {"58258012040BCC"}, + {"5952801209AA1C"}, + {"622570109E25D0"}, + {"63257010A6AA66"}, + {"6825801221756E"}, + {"70258012228EB2"}, + {"8225801234174E"}, + {"852580116C458E"}, + {"8825901009D75A"}, + {"89259010115ACD"}, + {"952580124BFB41"}, + {"9625801253FEC0"} +}; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tagid.hpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,32 @@ +/** + * @file tagid.hpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ + +#ifndef __TAGID_HPP +#define __TAGID_HPP + // ARCHIVO PARA DEFINIR TODOS LOS RFiD DE LOS CABEZALES Y TIEMPO ASOCIADO + extern const int TOTAL_PLACAS_A; + extern const int TOTAL_PLACAS_B; + extern const int TOTAL_PLACAS_C; + + extern const int GRUPO_A_AMARILLO; + extern const int GRUPO_B_AMARILLO; + extern const int GRUPO_C_AMARILLO; + extern const int GRUPO_DEFAULT_AMARILLO; + extern const int GRUPO_A_ROJO; + extern const int GRUPO_B_ROJO; + extern const int GRUPO_C_ROJO; + extern const int GRUPO_DEFAULT_ROJO; + + + extern char PLACAS_A[][15]; + extern char PLACAS_B[][15]; + extern char PLACAS_C[][15]; +#endif // __TAGID_HPP \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testing.cpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,84 @@ +/** + * @file testing.cpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ + +#include "mbed.h" +#include "constantes.hpp" + +extern Serial pcusb; +extern BusOut display_H; +extern BusOut display_dM; +extern BusOut display_uM; +extern BusOut torreLuz; +extern DigitalOut display_DP; + + + +void test_display7s() { +int x = 0; + pcusb.printf("\r\n*** PRUEBA DE DIGITOS ***"); + + // Apagar todo + torreLuz.write(COLOR_TORRE_LUZ[APAGADO_TL]); + display_uM.write(DIGITOS[APAGADO_7S]); + display_dM.write(DIGITOS[APAGADO_7S]); + display_H.write(DIGITOS[APAGADO_7S]); + display_DP = 0; + WatchdogRefresh(); + wait(5.0); + WatchdogRefresh(); + + + // Unidades de minutos + display_DP = 1; + pcusb.printf("\r\n\r\nUnidades de minuto:"); + torreLuz.write(COLOR_TORRE_LUZ[VERDE]); + for (x=0; x<11; x++) { + display_uM.write(DIGITOS[x]); + pcusb.printf("\r\n%d = %02X", x, DIGITOS[x]); + wait_us(750000); + } + + // Decenas de minutos + pcusb.printf("\r\n\r\nDecenas de minuto:"); + torreLuz.write(COLOR_TORRE_LUZ[AMARILLO]); + for (x=0; x<11; x++) { + display_dM.write(DIGITOS[x]); + pcusb.printf("\r\n%d = %02X", x, DIGITOS[x]); + wait_us(750000); + } + + // Horas + pcusb.printf("\r\n\r\nUnidades de hora:"); + torreLuz.write(COLOR_TORRE_LUZ[ROJO]); + for (x=0; x<11; x++) { + display_H.write(DIGITOS[x]); + pcusb.printf("\r\n%d = %02X", x, DIGITOS[x]); + wait_us(750000); + } + + // Mantener todo encendido por 3 minutos + pcusb.printf("\r\n\r\nMostrando 8:88"); + display_DP = 1; + display_uM.write(DIGITOS[OCHO_7S]); + display_dM.write(DIGITOS[OCHO_7S]); + display_H.write(DIGITOS[OCHO_7S]); + + // Espera de 3 minutos + pcusb.printf("\r\nEsperando %d segundos", (x*5)); + wait_us(3000000); + + torreLuz.write(COLOR_TORRE_LUZ[APAGADO_TL]); + display_uM.write(DIGITOS[APAGADO_7S]); + display_dM.write(DIGITOS[APAGADO_7S]); + display_H.write(DIGITOS[APAGADO_7S]); + display_DP = 0; + pcusb.printf("\r\n*** FIN DE LA PRUEBA ***\r\n"); +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testing.hpp Mon May 24 01:42:28 2021 -0600 @@ -0,0 +1,18 @@ +/** + * @file testing.hpp + * @author Felícito Manzano (felicito.manzano@detektor.com.sv) + * @brief + * @version 0.1 + * @date 2021-05-23 + * + * @copyright Copyright (c) 2021 + * + */ + + +#ifndef __TESTING_HPP +#define __TESTING_HPP + + void test_display7s(); + +#endif // __TESTING_HPP