Felícito Manzano
/
DTK_Guaria2_ABInBev
Proyecto ABInBev para la tarjeta Guaria 1/2.
Embed:
(wiki syntax)
Show/hide line numbers
fireup_exe.cpp
Go to the documentation of this file.
00001 /** 00002 * @file fireup_exe.cpp 00003 * @author Felícito Manzano (felicito.manzano@detektor.com.sv) 00004 * @brief 00005 * @version 0.1 00006 * @date 2021-01-14 00007 * 00008 * @copyright Copyright (c) 2021 00009 * 00010 */ 00011 00012 #include "mbed.h" 00013 #include "BufferedSerial.h" 00014 //#include "GT521FX.hpp" 00015 #include "New_GT521Fx.hpp " 00016 #include "playlist.hpp" 00017 #include "voice_cn_pa.hpp" 00018 #include "jq8400_voice.hpp " 00019 #include "teltonika_fmu130.hpp " 00020 #include "fireup_exe.hpp " 00021 #include "safety_tip_exe.hpp " 00022 #include "USBSerial.h" 00023 00024 extern BufferedSerial avl_uart; 00025 extern BufferedSerial fingerprint; 00026 //extern GT521FX fingerprint; 00027 extern DigitalOut out1_fingerprint; 00028 extern DigitalOut out3_gt521fx; 00029 extern DigitalOut out4_gt521fx; 00030 extern const char TCA_ID_LECTOR_HUE[]; 00031 extern const char IO_ENGINE_UNLOCK[]; 00032 extern Ticker tick_fingerprint; 00033 extern Ticker tick_safety_tip; 00034 extern USBSerial myPC_debug; 00035 00036 extern bool finterprint_flag_working; 00037 extern bool fingerprint_flag_poweroff; 00038 extern bool functionality_fingerprint_reader; 00039 extern bool flag_fingerprint_turOn; 00040 extern bool flag_driver_loggin; 00041 extern bool functionality_force_driver_buclke; 00042 extern bool estado_actual_cinturon_piloto; 00043 extern bool estado_actual_ignicion; 00044 extern bool functionality_safety_tip; 00045 extern bool ble_connection_state; 00046 extern float time_safety_tip; 00047 extern int flag_fingerprint_query; 00048 extern char gpio_buffer[]; 00049 00050 #define DEBUG_FU_CPP 1 00051 #define UP_FP_READER_GT521 1 00052 00053 /** 00054 * @brief 00055 * 00056 */ 00057 void query_fingerprint_reader() { 00058 flag_fingerprint_query = true; 00059 } 00060 00061 00062 /** 00063 * @brief 00064 * 00065 */ 00066 void process_Engine_FireUp() { 00067 00068 if (functionality_fingerprint_reader) { // Lector habilitado 00069 #ifdef DEBUG_FU_CPP 00070 myPC_debug.printf("EnFU - Lector de huella Habilitado\r\n"); 00071 #endif 00072 00073 if (functionality_force_driver_buclke) { // Cinturón habilitado 00074 #ifdef DEBUG_FU_CPP 00075 myPC_debug.printf("EnFU - Ctrn Piloto - Debe estar abrochado\r\n"); 00076 #endif 00077 if (estado_actual_cinturon_piloto && !(flag_driver_loggin)) { 00078 out3_gt521fx = out4_gt521fx = finterprint_flag_working = true; // Se activa el lector 00079 wait_us(500000); 00080 #ifdef DEBUG_FU_CPP 00081 myPC_debug.printf("EnFU - OUT3:TRUE"); 00082 #endif 00083 finterprint_flag_working = true; 00084 flag_fingerprint_turOn = true; 00085 jq8400_addQueue (VOICE_functionality_fingerprint_reader); 00086 #ifdef DEBUG_FU_CPP 00087 myPC_debug.printf("EnFU - Activar lector de Huella\r\n"); 00088 #endif 00089 tick_fingerprint.attach(&query_fingerprint_reader, 1.0); 00090 #if UP_FP_READER_GT521 == 1 00091 FP_Open(); 00092 #else 00093 #endif 00094 sprintf(gpio_buffer, "%s2", TCA_ID_LECTOR_HUE); 00095 tx_fmu130_message (gpio_buffer, &avl_uart); 00096 #ifdef DEBUG_FU_CPP 00097 myPC_debug.printf("%s\r\n", gpio_buffer); 00098 #endif 00099 } 00100 00101 } else { // Cinturon deshabilitado 00102 #ifdef DEBUG_FU_CPP 00103 myPC_debug.printf("EnFU - Ctrn Piloto - No se toma en consideracion\r\n"); 00104 #endif 00105 out3_gt521fx = out4_gt521fx = finterprint_flag_working = true; 00106 wait_us(500000); 00107 #ifdef DEBUG_FU_CPP 00108 myPC_debug.printf("EnFU - OUT3:TRUE"); 00109 #endif 00110 finterprint_flag_working = true; 00111 flag_fingerprint_turOn = true; 00112 jq8400_addQueue (VOICE_functionality_fingerprint_reader); 00113 #ifdef DEBUG_FU_CPP 00114 myPC_debug.printf("EnFU - Activar lector de Huella"); 00115 #endif 00116 tick_fingerprint.attach(&query_fingerprint_reader, 1.00); 00117 #if UP_FP_READER_GT521 == 1 00118 FP_Open(); 00119 #else 00120 #endif 00121 sprintf(gpio_buffer, "%s2", TCA_ID_LECTOR_HUE); 00122 tx_fmu130_message (gpio_buffer, &avl_uart); 00123 #ifdef DEBUG_FU_CPP 00124 myPC_debug.printf("%s\r\n", gpio_buffer); 00125 #endif 00126 } 00127 00128 00129 } else { // Lector deshabilitado 00130 #ifdef DEBUG_FU_CPP 00131 myPC_debug.printf("\r\nEnFU - Lector de huella Deshabilitado\r\n"); 00132 #endif 00133 if (functionality_force_driver_buclke) { // Cinturón habilitado 00134 if (!(flag_driver_loggin)) { 00135 #ifdef DEBUG_FU_CPP 00136 myPC_debug.printf("\r\nEnFU - Ctrn Piloto - Debe estar abrochado\r\n"); 00137 #endif 00138 if (estado_actual_cinturon_piloto) { 00139 flag_driver_loggin = true; 00140 jq8400_addQueue (VOICE_WELLCOME); 00141 if (ble_connection_state) { 00142 // No hacer nada 00143 } else { 00144 //jq8400_addQueue(VOICE_FP_AUTH_NO_BLUETOOTH); 00145 } 00146 #ifdef DEBUG_FU_CPP 00147 myPC_debug.printf("EnFU IGN=ON - Permitir encendido con lector Deshabilitado y cinturon abrochado\r\n"); 00148 #endif 00149 tx_fmu130_command(IO_ENGINE_UNLOCK, &avl_uart); 00150 out1_fingerprint = 1; 00151 wait_us(1000000); 00152 out1_fingerprint = 0; 00153 if (functionality_safety_tip) { 00154 #ifdef DEBUG_FU_CPP 00155 myPC_debug.printf("FP - Ticker de Tip de Seguridad Iniciado\r\n"); 00156 #endif 00157 tick_safety_tip.attach(&play_SafetyTip, time_safety_tip); 00158 } 00159 } 00160 } 00161 00162 } else { // Cinturón deshabilitado 00163 #ifdef DEBUG_FU_CPP 00164 myPC_debug.printf("\r\nEnFU - Ctrn Piloto - No se toma en consideracion\r\n"); 00165 #endif 00166 jq8400_addQueue (VOICE_WELLCOME); 00167 if (functionality_safety_tip) { 00168 #ifdef DEBUG_FU_CPP 00169 myPC_debug.printf("FP - Ticker de Tip de Seguridad Iniciado\r\n"); 00170 #endif 00171 tick_safety_tip.attach(&play_SafetyTip, time_safety_tip); 00172 } 00173 } 00174 } 00175 } 00176 00177 /** 00178 * @brief 00179 * 00180 */ 00181 void process_SeatBelt_FireUp() { 00182 if (functionality_fingerprint_reader) { // Lector habilitado 00183 if (functionality_force_driver_buclke) { // Cinturón habilitado 00184 if (estado_actual_ignicion && !(flag_driver_loggin)) { 00185 out3_gt521fx = out4_gt521fx = finterprint_flag_working = true; 00186 wait_us(500000); 00187 finterprint_flag_working = true; 00188 jq8400_addQueue (VOICE_functionality_fingerprint_reader); 00189 tick_fingerprint.attach(&query_fingerprint_reader, 1.00); 00190 #ifdef DEBUG_FU_CPP 00191 myPC_debug.printf("EnFU - OUT3:TRUE"); 00192 myPC_debug.printf("EnFU - Ignicion debe estar ON\r\n"); 00193 myPC_debug.printf("EnFU - Activar lector de Huella\r\n"); 00194 #endif 00195 #if UP_FP_READER_GT521 == 1 00196 FP_Open(); 00197 #else 00198 #endif 00199 00200 flag_fingerprint_turOn = true; 00201 sprintf(gpio_buffer, "%s2", TCA_ID_LECTOR_HUE); 00202 #ifdef DEBUG_FU_CPP 00203 myPC_debug.printf("%s\r\n", gpio_buffer); 00204 #endif 00205 tx_fmu130_message (gpio_buffer, &avl_uart); 00206 } 00207 } 00208 } else { // Lector deshabilitado 00209 if (estado_actual_ignicion && functionality_force_driver_buclke) { 00210 if (!(flag_driver_loggin)) { 00211 flag_driver_loggin = true; 00212 #ifdef DEBUG_FU_CPP 00213 myPC_debug.printf("EnFU - Permitir encendido con lector Deshabilitado y Cinturon abrochado\r\n"); 00214 #endif 00215 tx_fmu130_command(IO_ENGINE_UNLOCK, &avl_uart); 00216 out1_fingerprint = 1; 00217 wait_us(1000000); 00218 out1_fingerprint = 0; 00219 jq8400_addQueue (VOICE_WELLCOME); 00220 if (ble_connection_state) { 00221 // No hacer nada 00222 } else { 00223 //jq8400_addQueue(VOICE_FP_AUTH_NO_BLUETOOTH); 00224 } 00225 if (functionality_safety_tip) { 00226 #ifdef DEBUG_FU_CPP 00227 myPC_debug.printf("FP - Ticker de Tip de Seguridad Iniciado\r\n"); 00228 #endif 00229 tick_safety_tip.attach(&play_SafetyTip, time_safety_tip); 00230 } 00231 } 00232 } 00233 } 00234 }
Generated on Thu Jul 28 2022 19:27:02 by 1.7.2