teste de publish
Dependencies: DS1820 HighSpeedAnalogIn devices mbed
serialPC.cpp
00001 #include "serialPC.h" 00002 00003 osTimerId serialPC::timer_pacote; 00004 bool serialPC::startTimer_pacote; 00005 00006 /*Timers*/ 00007 //osTimerDef( "nomeDoTimer", "Função chamada pelo timer when match") 00008 osTimerDef(timerProcessaPacotePC,serialPC::processaPacotePC); 00009 /*Timers*/ 00010 00011 void serialPC::serialPC_init(){ 00012 //Instnciando o timer de processamento de pacotes entrantes na serial PC 00013 pc.baud(115200); //Inicialização de recurso Serial uart pc com baudrate 230400 00014 pc.printf("Serial PC inicializado.\n"); //Exibe mensagem de inicialização da serial pc 00015 00016 //Criando timer_pacote 00017 serialPC::timer_pacote = osTimerCreate(osTimer(timerProcessaPacotePC),osTimerOnce,NULL); 00018 00019 //Associando função a ISR da serial PC 00020 pc.attach(&serialPC::isr_serialPC); //Setando uma função para ISR Serial 0 (Serial pc) 00021 } 00022 void serialPC::isr_serialPC(){ 00023 uint32_t RBR = LPC_UART0->RBR; //Reset RBR interrupt flag e captura o caractere entrante 00024 00025 bufPC.putc(RBR); 00026 serialPC::startTimer_pacote=true; 00027 osSignalSet(idThreadTimers, 0x1); 00028 } 00029 00030 void serialPC::processaPacotePC(void const *args){ 00031 char * bufIn; 00032 char *ptr; 00033 uint16_t bufLength = bufPC.getLength(); 00034 bufIn = bufPC.get(); 00035 00036 00037 if(strstr(bufIn,"execAct(")){ 00038 strtok(bufIn,"("); 00039 act=atoi(strtok(NULL,")")); 00040 boolExecAct = true; 00041 return; 00042 } 00043 00044 if(strstr(bufIn,"modem:")!=NULL){ 00045 bufIn = &bufIn[6]; 00046 pc.printf("Mensagem ao modem <%s>.\r\n",bufIn); 00047 modemCom::sendToModem(bufIn,1,NULL,NULL,150,1,1); 00048 pc.printf("Mesagem do modem <%s>.\r\n",bufModem.getRowBuffer()); 00049 return; 00050 } 00051 00052 00053 if(strstr(bufIn,"escreveFlash")!=NULL){ 00054 NVIC_DeInit(); 00055 bootLoader(); 00056 } 00057 00058 00059 if(strstr(bufIn,"config")!=NULL){ 00060 sdCard::exibeArquivo(&sdCard::config); 00061 } 00062 00063 if(strstr(bufIn,"sensUP")!=NULL){ 00064 temperaturas[0]=55; 00065 } 00066 00067 if(strstr(bufIn,"sensDOWN")!=NULL){ 00068 temperaturas[0]=0; 00069 } 00070 00071 if(strstr(bufIn,"devices")!=NULL){ 00072 sdCard::exibeArquivo(&sdCard::devices); 00073 } 00074 00075 if(strstr(bufIn,"testaTudoDevices()")!=NULL){ 00076 testaTudoDevices(); 00077 } 00078 00079 ptr=strstr(bufIn,"deleteArmazenamento"); 00080 if(ptr){ 00081 pc.printf("Deletando banks.\r\n"); 00082 sdCard::deleteBanks(2); 00083 } 00084 00085 if(strstr(bufIn,"enviaDadosAoServer")){ 00086 eventosRTC::rotinaEnvioDeDados=maxTentativasEnvioDados; 00087 modemCom::timeOutEnvioDados=maxTimeEnvioDados; 00088 } 00089 00090 if(strstr(bufIn,"wdtReset")){ 00091 pc.printf("Comandando Reset por wdt.\r\n"); 00092 osDelay(50); 00093 diversos::wdt.kick(0.1); 00094 while(true); 00095 } 00096 00097 if(strstr(bufIn,"debug")){ 00098 debug = !debug; 00099 } 00100 00101 if(strstr(bufIn,"xereta")){ 00102 xeretaModem = !xeretaModem; 00103 } 00104 00105 if(strstr(bufIn,"excluiArquivoPeloNome:")!=NULL){ 00106 strtok(bufIn,":"); 00107 ptr = strtok(NULL,":"); 00108 remove(ptr); 00109 return; 00110 } 00111 00112 if(strstr(bufIn,"excluiArquivo:devices.cfg")!=NULL){ 00113 sdCard::excluiArquivo(&sdCard::devices); 00114 } 00115 }
Generated on Wed Jul 13 2022 12:46:24 by 1.7.2