teste de publish

Dependencies:   DS1820 HighSpeedAnalogIn devices mbed

Committer:
brunofgc
Date:
Sat May 26 13:00:00 2018 +0000
Revision:
31:a1ba855c6e8a
Parent:
30:8a06a85d8807
Child:
33:a60abda630f7
Versao com bug de sobrescrita em buffer modbus quando faz retentativa. (Mesmo buffer de entrada e saida).

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 4:13ff9c81dc10 31 char * bufIn;
brunofgc 4:13ff9c81dc10 32 char *ptr;
brunofgc 4:13ff9c81dc10 33 char *scanPtr;
brunofgc 0:1c0a769988ee 34 uint16_t bufLength = bufPC.getLength();
brunofgc 0:1c0a769988ee 35 bufIn = bufPC.get();
brunofgc 0:1c0a769988ee 36
brunofgc 0:1c0a769988ee 37
brunofgc 30:8a06a85d8807 38 static bool recebendoDeviceCfg = false;
brunofgc 30:8a06a85d8807 39
brunofgc 7:ae9c47f62946 40 if(strstr(bufIn,"execAct(")){
brunofgc 7:ae9c47f62946 41 strtok(bufIn,"(");
brunofgc 7:ae9c47f62946 42 act=atoi(strtok(NULL,")"));
brunofgc 7:ae9c47f62946 43 boolExecAct = true;
brunofgc 7:ae9c47f62946 44 return;
brunofgc 7:ae9c47f62946 45 }
brunofgc 30:8a06a85d8807 46
brunofgc 0:1c0a769988ee 47 if(strstr(bufIn,"modem:")!=NULL){
brunofgc 0:1c0a769988ee 48 bufIn = &bufIn[6];
brunofgc 0:1c0a769988ee 49 pc.printf("Mensagem ao modem <%s>.\r\n",bufIn);
brunofgc 31:a1ba855c6e8a 50 modemCom::sendToModem(bufIn,1,NULL,NULL,150,1,1);
brunofgc 7:ae9c47f62946 51 pc.printf("Mesagem do modem <%s>.\r\n",bufModem.getRowBuffer());
brunofgc 0:1c0a769988ee 52 return;
brunofgc 0:1c0a769988ee 53 }
brunofgc 30:8a06a85d8807 54
brunofgc 30:8a06a85d8807 55 if(strstr(bufIn,"config")!=NULL){
brunofgc 9:cf406384efd9 56 sdCard::exibeArquivo(&sdCard::config);
brunofgc 9:cf406384efd9 57 }
brunofgc 9:cf406384efd9 58
brunofgc 30:8a06a85d8807 59 if(strstr(bufIn,"devices")!=NULL){
brunofgc 30:8a06a85d8807 60 sdCard::exibeArquivo(&sdCard::devices);
brunofgc 30:8a06a85d8807 61 }
brunofgc 2:55b7b466e742 62
brunofgc 1:0e0967c88590 63 if(strstr(bufIn,"testaTudoDevices()")!=NULL){
brunofgc 1:0e0967c88590 64 testaTudoDevices();
brunofgc 0:1c0a769988ee 65 }
brunofgc 0:1c0a769988ee 66
brunofgc 29:823a9da3696b 67 ptr=strstr(bufIn,"deleteArmazenamento");
brunofgc 29:823a9da3696b 68 if(ptr){
brunofgc 30:8a06a85d8807 69 pc.printf("Deletando banks.\r\n");
brunofgc 30:8a06a85d8807 70 sdCard::deleteBanks(2);
brunofgc 30:8a06a85d8807 71 }
brunofgc 30:8a06a85d8807 72
brunofgc 30:8a06a85d8807 73 if(strstr(bufIn,"enviaDadosAoServer")){
brunofgc 30:8a06a85d8807 74 eventosRTC::rotinaEnvioDeDados=maxTentativasEnvioDados;
brunofgc 29:823a9da3696b 75 }
brunofgc 30:8a06a85d8807 76
brunofgc 0:1c0a769988ee 77
brunofgc 21:b9315cdd9275 78 if(strstr(bufIn,"debug")){
brunofgc 21:b9315cdd9275 79 if(debug){debug = false;}
brunofgc 21:b9315cdd9275 80 else{debug = true;}
brunofgc 21:b9315cdd9275 81 }
brunofgc 0:1c0a769988ee 82
brunofgc 30:8a06a85d8807 83 if(strstr(bufIn,"xereta")){
brunofgc 30:8a06a85d8807 84 if(xeretaModem){debug = false;}
brunofgc 30:8a06a85d8807 85 else{xeretaModem = true;}
brunofgc 30:8a06a85d8807 86 }
brunofgc 10:263c093f8977 87
brunofgc 25:a6da63ed025b 88 if(strstr(bufIn,"excluiArquivoPeloNome:")!=NULL){
brunofgc 25:a6da63ed025b 89 strtok(bufIn,":");
brunofgc 25:a6da63ed025b 90 ptr = strtok(NULL,":");
brunofgc 25:a6da63ed025b 91 remove(ptr);
brunofgc 25:a6da63ed025b 92 return;
brunofgc 25:a6da63ed025b 93 }
brunofgc 0:1c0a769988ee 94
brunofgc 0:1c0a769988ee 95 if(strstr(bufIn,"excluiArquivo:devices.cfg")!=NULL){
brunofgc 0:1c0a769988ee 96 sdCard::excluiArquivo(&sdCard::devices);
brunofgc 30:8a06a85d8807 97 }
brunofgc 0:1c0a769988ee 98 }