teste de publish

Dependencies:   DS1820 HighSpeedAnalogIn devices mbed

Committer:
brunofgc
Date:
Wed May 10 12:57:13 2017 +0000
Revision:
2:55b7b466e742
Parent:
1:0e0967c88590
Child:
4:13ff9c81dc10
Ainda com bug em configRede.htm

Who changed what in which revision?

UserRevisionLine numberNew contents of line
brunofgc 0:1c0a769988ee 1 #include "serialPC.h"
brunofgc 0:1c0a769988ee 2
brunofgc 0:1c0a769988ee 3 osTimerId serialPC::timer_pacote;
brunofgc 0:1c0a769988ee 4 bool serialPC::startTimer_pacote;
brunofgc 0:1c0a769988ee 5
brunofgc 0:1c0a769988ee 6 /*Timers*/
brunofgc 0:1c0a769988ee 7 //osTimerDef( "nomeDoTimer", "Função chamada pelo timer when match")
brunofgc 0:1c0a769988ee 8 osTimerDef(timerProcessaPacotePC,serialPC::processaPacotePC);
brunofgc 0:1c0a769988ee 9 /*Timers*/
brunofgc 0:1c0a769988ee 10
brunofgc 0:1c0a769988ee 11 void serialPC::serialPC_init(){
brunofgc 0:1c0a769988ee 12 //Instnciando o timer de processamento de pacotes entrantes na serial PC
brunofgc 0:1c0a769988ee 13 pc.baud(230400); //Inicialização de recurso Serial uart pc com baudrate 230400
brunofgc 0:1c0a769988ee 14 pc.printf("Serial PC inicializado.\n"); //Exibe mensagem de inicialização da serial pc
brunofgc 0:1c0a769988ee 15
brunofgc 0:1c0a769988ee 16 //Criando timer_pacote
brunofgc 0:1c0a769988ee 17 serialPC::timer_pacote = osTimerCreate(osTimer(timerProcessaPacotePC),osTimerOnce,NULL);
brunofgc 0:1c0a769988ee 18
brunofgc 0:1c0a769988ee 19 //Associando função a ISR da serial PC
brunofgc 0:1c0a769988ee 20 pc.attach(&serialPC::isr_serialPC); //Setando uma função para ISR Serial 0 (Serial pc)
brunofgc 0:1c0a769988ee 21 }
brunofgc 0:1c0a769988ee 22 void serialPC::isr_serialPC(){
brunofgc 0:1c0a769988ee 23 uint32_t RBR = LPC_UART0->RBR; //Reset RBR interrupt flag e captura o caractere entrante
brunofgc 0:1c0a769988ee 24
brunofgc 0:1c0a769988ee 25 bufPC.putc(RBR);
brunofgc 0:1c0a769988ee 26 serialPC::startTimer_pacote=true;
brunofgc 0:1c0a769988ee 27 osSignalSet(idThreadTimers, 0x1);
brunofgc 0:1c0a769988ee 28 }
brunofgc 0:1c0a769988ee 29
brunofgc 0:1c0a769988ee 30 void serialPC::processaPacotePC(void const *args){
brunofgc 0:1c0a769988ee 31 char * bufIn;
brunofgc 0:1c0a769988ee 32 uint16_t bufLength = bufPC.getLength();
brunofgc 0:1c0a769988ee 33 bufIn = bufPC.get();
brunofgc 0:1c0a769988ee 34
brunofgc 0:1c0a769988ee 35
brunofgc 0:1c0a769988ee 36 static bool recebendoDeviceCfg = false;
brunofgc 0:1c0a769988ee 37
brunofgc 0:1c0a769988ee 38 if(strstr(bufIn,"cmd/StartSendDeviceCfg;>")){
brunofgc 0:1c0a769988ee 39 recebendoDeviceCfg = true;
brunofgc 0:1c0a769988ee 40 return;
brunofgc 0:1c0a769988ee 41 }
brunofgc 0:1c0a769988ee 42
brunofgc 0:1c0a769988ee 43 if(strstr(bufIn,"cmd/StopSendDeviceCfg;>")){
brunofgc 0:1c0a769988ee 44 recebendoDeviceCfg = false;
brunofgc 0:1c0a769988ee 45 return;
brunofgc 0:1c0a769988ee 46 }
brunofgc 0:1c0a769988ee 47
brunofgc 0:1c0a769988ee 48 if(recebendoDeviceCfg){
brunofgc 0:1c0a769988ee 49 sdCard::insereDadosArquivo(&sdCard::devices,bufIn,bufLength);
brunofgc 0:1c0a769988ee 50 pc.printf("Caracteres inseridos %lu\n",bufLength);
brunofgc 0:1c0a769988ee 51 return;
brunofgc 0:1c0a769988ee 52 }
brunofgc 0:1c0a769988ee 53
brunofgc 0:1c0a769988ee 54 if(strstr(bufIn,"modem:")!=NULL){
brunofgc 0:1c0a769988ee 55 bufIn = &bufIn[6];
brunofgc 0:1c0a769988ee 56 pc.printf("Mensagem ao modem <%s>.\r\n",bufIn);
brunofgc 0:1c0a769988ee 57 modem.printf("%s",bufIn);
brunofgc 0:1c0a769988ee 58 modemCom::status.exibeBufModem=true;
brunofgc 0:1c0a769988ee 59 return;
brunofgc 0:1c0a769988ee 60 }
brunofgc 0:1c0a769988ee 61
brunofgc 0:1c0a769988ee 62 if(strstr(bufIn,"exibeArquivo:armazenamento.txt")!=NULL){
brunofgc 0:1c0a769988ee 63 sdCard::exibeArquivo(&sdCard::armazenamento);
brunofgc 0:1c0a769988ee 64 return;
brunofgc 2:55b7b466e742 65 }
brunofgc 2:55b7b466e742 66
brunofgc 2:55b7b466e742 67 if(strstr(bufIn,"resetDigitais()")!=NULL){
brunofgc 2:55b7b466e742 68 SD_OE_R = 0;
brunofgc 2:55b7b466e742 69 osDelay(50);
brunofgc 2:55b7b466e742 70 SD_OE_R = 1;
brunofgc 2:55b7b466e742 71 return;
brunofgc 0:1c0a769988ee 72 }
brunofgc 2:55b7b466e742 73
brunofgc 2:55b7b466e742 74
brunofgc 1:0e0967c88590 75 if(strstr(bufIn,"testaTudoDevices()")!=NULL){
brunofgc 1:0e0967c88590 76 testaTudoDevices();
brunofgc 1:0e0967c88590 77 return;
brunofgc 1:0e0967c88590 78 }
brunofgc 1:0e0967c88590 79
brunofgc 0:1c0a769988ee 80
brunofgc 0:1c0a769988ee 81 if(strstr(bufIn,"exibeArquivo:tempFile.bin")!=NULL){
brunofgc 0:1c0a769988ee 82 sdCard::exibeArquivo(&sdCard::tempFile);
brunofgc 0:1c0a769988ee 83 return;
brunofgc 0:1c0a769988ee 84 }
brunofgc 0:1c0a769988ee 85
brunofgc 0:1c0a769988ee 86 if(strstr(bufIn,"exibeArquivo:envio.txt")!=NULL){
brunofgc 0:1c0a769988ee 87 sdCard::exibeArquivo(&sdCard::envio);
brunofgc 0:1c0a769988ee 88 return;
brunofgc 0:1c0a769988ee 89 }
brunofgc 0:1c0a769988ee 90
brunofgc 0:1c0a769988ee 91 if(strstr(bufIn,"enviaDadosAoServer")){
brunofgc 1:0e0967c88590 92 eventosRTC::rotina15Minutos=true;
brunofgc 0:1c0a769988ee 93 return;
brunofgc 0:1c0a769988ee 94 }
brunofgc 0:1c0a769988ee 95
brunofgc 2:55b7b466e742 96 if(strstr(bufIn,"enviaStatusAoServer")){
brunofgc 2:55b7b466e742 97 enviaStatusAoServer = true;
brunofgc 2:55b7b466e742 98 return;
brunofgc 2:55b7b466e742 99 }
brunofgc 2:55b7b466e742 100
brunofgc 0:1c0a769988ee 101 if(strstr(bufIn,"enviaArquivoDevices")){
brunofgc 0:1c0a769988ee 102 arquivoEnvioPointer = &sdCard::devices;
brunofgc 0:1c0a769988ee 103 return;
brunofgc 0:1c0a769988ee 104 }
brunofgc 0:1c0a769988ee 105
brunofgc 0:1c0a769988ee 106 if(strstr(bufIn,"excluiArquivo:armazenamento.txt")!=NULL){
brunofgc 0:1c0a769988ee 107 sdCard::excluiArquivo(&sdCard::armazenamento);
brunofgc 0:1c0a769988ee 108 return;
brunofgc 0:1c0a769988ee 109 }
brunofgc 0:1c0a769988ee 110
brunofgc 0:1c0a769988ee 111 if(strstr(bufIn,"excluiArquivo:envio.txt")!=NULL){
brunofgc 0:1c0a769988ee 112 sdCard::excluiArquivo(&sdCard::envio);
brunofgc 0:1c0a769988ee 113 return;
brunofgc 0:1c0a769988ee 114 }
brunofgc 0:1c0a769988ee 115
brunofgc 0:1c0a769988ee 116 if(strstr(bufIn,"excluiArquivo:devices.cfg")!=NULL){
brunofgc 0:1c0a769988ee 117 sdCard::excluiArquivo(&sdCard::devices);
brunofgc 0:1c0a769988ee 118 return;
brunofgc 0:1c0a769988ee 119 }
brunofgc 0:1c0a769988ee 120
brunofgc 0:1c0a769988ee 121 if(strstr(bufIn,"exibeArquivo:devices.cfg")!=NULL){
brunofgc 0:1c0a769988ee 122 sdCard::exibeArquivo(&sdCard::devices);
brunofgc 0:1c0a769988ee 123 return;
brunofgc 0:1c0a769988ee 124 }
brunofgc 0:1c0a769988ee 125 if(strstr(bufIn,"writeReadingsToSD()")){
brunofgc 0:1c0a769988ee 126 eventosRTC::rotina15Minutos = true;
brunofgc 0:1c0a769988ee 127 return;
brunofgc 0:1c0a769988ee 128 }
brunofgc 0:1c0a769988ee 129
brunofgc 0:1c0a769988ee 130 //bufLength
brunofgc 0:1c0a769988ee 131 /*
brunofgc 0:1c0a769988ee 132 stack overflow de thread...
brunofgc 0:1c0a769988ee 133 if(strstr(bufIn,"execAct(")){
brunofgc 0:1c0a769988ee 134 strtok(bufIn,"(");
brunofgc 0:1c0a769988ee 135 bufLength = atoi(strtok(NULL,")"));
brunofgc 0:1c0a769988ee 136 dispositivos[0]->execAct(bufLength);
brunofgc 0:1c0a769988ee 137 return;
brunofgc 0:1c0a769988ee 138 }
brunofgc 0:1c0a769988ee 139 */
brunofgc 0:1c0a769988ee 140 //Se chegou aqui é pq não foi uma mensagem reconhecida.
brunofgc 0:1c0a769988ee 141 pc.printf("Lido do CircularBuffer PC <%s>.\r\n",bufIn);
brunofgc 0:1c0a769988ee 142 }