teste de publish
Dependencies: DS1820 HighSpeedAnalogIn devices mbed
diversos.cpp@4:13ff9c81dc10, 2017-06-02 (annotated)
- Committer:
- brunofgc
- Date:
- Fri Jun 02 13:31:56 2017 +0000
- Revision:
- 4:13ff9c81dc10
- Parent:
- 3:9598af355293
- Child:
- 5:7801f913384e
Vers?o Est?vel instalada no AP201 antes de incluir as scheduleExceptions.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
brunofgc | 0:1c0a769988ee | 1 | #include "diversos.h" |
brunofgc | 0:1c0a769988ee | 2 | bool eventosRTC::segundos; |
brunofgc | 0:1c0a769988ee | 3 | bool eventosRTC::minutos; |
brunofgc | 0:1c0a769988ee | 4 | bool eventosRTC::rotina10Segundos; |
brunofgc | 0:1c0a769988ee | 5 | bool eventosRTC::rotina15Minutos; |
brunofgc | 0:1c0a769988ee | 6 | bool eventosRTC::rotina1hora; |
brunofgc | 0:1c0a769988ee | 7 | bool eventosRTC::rotina1segundo; |
brunofgc | 0:1c0a769988ee | 8 | WatchdogTimer diversos::wdt; |
brunofgc | 0:1c0a769988ee | 9 | //char diversos::msg[200]; |
brunofgc | 0:1c0a769988ee | 10 | //bool eventosRTC::hora_completa; |
brunofgc | 0:1c0a769988ee | 11 | char commands::buffer[tamBufferCommands]; |
brunofgc | 0:1c0a769988ee | 12 | |
brunofgc | 0:1c0a769988ee | 13 | /*void WatchdogTimer::WatchdogTimer(void){ |
brunofgc | 0:1c0a769988ee | 14 | //Constructor |
brunofgc | 0:1c0a769988ee | 15 | }*/ |
brunofgc | 0:1c0a769988ee | 16 | |
brunofgc | 0:1c0a769988ee | 17 | uint32_t diversos::memAvailable(){ |
brunofgc | 0:1c0a769988ee | 18 | char stackVariable; |
brunofgc | 0:1c0a769988ee | 19 | char *heap; |
brunofgc | 0:1c0a769988ee | 20 | uint32_t result; |
brunofgc | 0:1c0a769988ee | 21 | heap = (char*)malloc(1); |
brunofgc | 0:1c0a769988ee | 22 | result = (uint32_t) ((&stackVariable) - heap); |
brunofgc | 0:1c0a769988ee | 23 | free(heap); |
brunofgc | 0:1c0a769988ee | 24 | return result; |
brunofgc | 0:1c0a769988ee | 25 | } |
brunofgc | 0:1c0a769988ee | 26 | |
brunofgc | 0:1c0a769988ee | 27 | void WatchdogTimer::kick(float s) { |
brunofgc | 0:1c0a769988ee | 28 | LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK |
brunofgc | 0:1c0a769988ee | 29 | uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4 |
brunofgc | 0:1c0a769988ee | 30 | LPC_WDT->WDTC = s * (float)clk; |
brunofgc | 0:1c0a769988ee | 31 | LPC_WDT->WDMOD = 0x3; // Enabled and Reset |
brunofgc | 0:1c0a769988ee | 32 | kick(); |
brunofgc | 0:1c0a769988ee | 33 | } |
brunofgc | 0:1c0a769988ee | 34 | // "kick" or "feed" the dog - reset the watchdog timer |
brunofgc | 0:1c0a769988ee | 35 | // by writing this required bit pattern |
brunofgc | 0:1c0a769988ee | 36 | void WatchdogTimer::kick() { |
brunofgc | 0:1c0a769988ee | 37 | LPC_WDT->WDFEED = 0xAA; |
brunofgc | 0:1c0a769988ee | 38 | LPC_WDT->WDFEED = 0x55; |
brunofgc | 0:1c0a769988ee | 39 | } |
brunofgc | 0:1c0a769988ee | 40 | |
brunofgc | 0:1c0a769988ee | 41 | /*double diversos::stringToFloat(char *p,uint16_t max){ |
brunofgc | 0:1c0a769988ee | 42 | uint16_t caractere=0; |
brunofgc | 0:1c0a769988ee | 43 | double iPart=0.0,dPart=0.0,f=0.0,mult=0.1; |
brunofgc | 0:1c0a769988ee | 44 | while(*p != '.') { |
brunofgc | 0:1c0a769988ee | 45 | caractere++; |
brunofgc | 0:1c0a769988ee | 46 | if(caractere>(max-1)){return 0.0;} |
brunofgc | 0:1c0a769988ee | 47 | iPart = (iPart*10) + (double)((*(p++)-'0')); |
brunofgc | 0:1c0a769988ee | 48 | } |
brunofgc | 0:1c0a769988ee | 49 | p++; |
brunofgc | 0:1c0a769988ee | 50 | while(*p!= '\0') { |
brunofgc | 0:1c0a769988ee | 51 | if(caractere>(max-1)){return 0.0;} |
brunofgc | 0:1c0a769988ee | 52 | dPart += (double)(((*(p++)-'0'))*mult); |
brunofgc | 0:1c0a769988ee | 53 | mult /= 10; |
brunofgc | 0:1c0a769988ee | 54 | } |
brunofgc | 0:1c0a769988ee | 55 | f = iPart + dPart; |
brunofgc | 0:1c0a769988ee | 56 | return f; |
brunofgc | 0:1c0a769988ee | 57 | }*/ |
brunofgc | 0:1c0a769988ee | 58 | |
brunofgc | 0:1c0a769988ee | 59 | /*double diversos::stringToFloat(char *p,uint16_t max){ |
brunofgc | 0:1c0a769988ee | 60 | uint16_t caractere=0; |
brunofgc | 0:1c0a769988ee | 61 | double iPart=0.0,dPart=0.0,f=0.0,mult=0.1; |
brunofgc | 0:1c0a769988ee | 62 | while(p[caractere] != '.'){ |
brunofgc | 0:1c0a769988ee | 63 | caractere++; |
brunofgc | 0:1c0a769988ee | 64 | if(caractere>(max-1)){return 0.0;} |
brunofgc | 0:1c0a769988ee | 65 | iPart = (iPart*10) + (((uint8_t)p[caractere])-30); |
brunofgc | 0:1c0a769988ee | 66 | } |
brunofgc | 0:1c0a769988ee | 67 | caractere++; |
brunofgc | 0:1c0a769988ee | 68 | while(p[caractere]!= '\0'){ |
brunofgc | 0:1c0a769988ee | 69 | if(caractere>(max-1)){return 0.0;} |
brunofgc | 0:1c0a769988ee | 70 | dPart += (((uint8_t)p[caractere])-30)*mult; |
brunofgc | 0:1c0a769988ee | 71 | mult /= 10; |
brunofgc | 0:1c0a769988ee | 72 | } |
brunofgc | 0:1c0a769988ee | 73 | f = iPart + dPart; |
brunofgc | 0:1c0a769988ee | 74 | return f; |
brunofgc | 0:1c0a769988ee | 75 | }*/ |
brunofgc | 0:1c0a769988ee | 76 | |
brunofgc | 3:9598af355293 | 77 | void diversos::strReplace(char *str, char *find, char *replace){ |
brunofgc | 3:9598af355293 | 78 | char aux[100]; |
brunofgc | 3:9598af355293 | 79 | char *ptr; |
brunofgc | 3:9598af355293 | 80 | char replaced = 0; |
brunofgc | 3:9598af355293 | 81 | char maxIterations = 0; |
brunofgc | 3:9598af355293 | 82 | replaced = 0; |
brunofgc | 3:9598af355293 | 83 | strcpy(aux,""); |
brunofgc | 3:9598af355293 | 84 | ptr = strtok(str,find); |
brunofgc | 3:9598af355293 | 85 | while((ptr!=NULL)&&(maxIterations<9)){ |
brunofgc | 3:9598af355293 | 86 | replaced = 1; |
brunofgc | 3:9598af355293 | 87 | maxIterations++; |
brunofgc | 3:9598af355293 | 88 | strcat(aux,ptr); |
brunofgc | 3:9598af355293 | 89 | strcat(aux,replace); |
brunofgc | 3:9598af355293 | 90 | ptr = strtok(NULL,find); |
brunofgc | 3:9598af355293 | 91 | pc.printf("Tirando <%s> em <%s>.\r\n",find,str); |
brunofgc | 3:9598af355293 | 92 | } |
brunofgc | 3:9598af355293 | 93 | if(replaced){ |
brunofgc | 3:9598af355293 | 94 | aux[strlen(aux)-1]=0; |
brunofgc | 3:9598af355293 | 95 | strcpy(str,aux); |
brunofgc | 3:9598af355293 | 96 | } |
brunofgc | 3:9598af355293 | 97 | //-------------------- |
brunofgc | 3:9598af355293 | 98 | } |
brunofgc | 3:9598af355293 | 99 | |
brunofgc | 4:13ff9c81dc10 | 100 | void diversos::processaPulsosEDs(){ |
brunofgc | 4:13ff9c81dc10 | 101 | if(ED1 && (!estadoAnteriorEDs[0])){pulsosEDs[0]++;} |
brunofgc | 4:13ff9c81dc10 | 102 | estadoAnteriorEDs[0]=ED1; |
brunofgc | 4:13ff9c81dc10 | 103 | if(ED2 && (!estadoAnteriorEDs[1])){pulsosEDs[1]++;} |
brunofgc | 4:13ff9c81dc10 | 104 | estadoAnteriorEDs[1]=ED2; |
brunofgc | 4:13ff9c81dc10 | 105 | if(ED3 && (!estadoAnteriorEDs[2])){pulsosEDs[2]++;} |
brunofgc | 4:13ff9c81dc10 | 106 | estadoAnteriorEDs[2]=ED3; |
brunofgc | 4:13ff9c81dc10 | 107 | if(ED4 && (!estadoAnteriorEDs[3])){pulsosEDs[3]++;} |
brunofgc | 4:13ff9c81dc10 | 108 | estadoAnteriorEDs[3]=ED4; |
brunofgc | 4:13ff9c81dc10 | 109 | if(ED5 && (!estadoAnteriorEDs[4])){pulsosEDs[4]++;} |
brunofgc | 4:13ff9c81dc10 | 110 | estadoAnteriorEDs[4]=ED5; |
brunofgc | 4:13ff9c81dc10 | 111 | if(ED6 && (!estadoAnteriorEDs[5])){pulsosEDs[5]++;} |
brunofgc | 4:13ff9c81dc10 | 112 | estadoAnteriorEDs[5]=ED6; |
brunofgc | 4:13ff9c81dc10 | 113 | if(ED7 && (!estadoAnteriorEDs[6])){pulsosEDs[6]++;} |
brunofgc | 4:13ff9c81dc10 | 114 | estadoAnteriorEDs[6]=ED7; |
brunofgc | 4:13ff9c81dc10 | 115 | if(ED8 && (!estadoAnteriorEDs[7])){pulsosEDs[7]++;} |
brunofgc | 4:13ff9c81dc10 | 116 | estadoAnteriorEDs[7]=ED8; |
brunofgc | 4:13ff9c81dc10 | 117 | if(ED9 && (!estadoAnteriorEDs[8])){pulsosEDs[8]++;} |
brunofgc | 4:13ff9c81dc10 | 118 | estadoAnteriorEDs[8]=ED9; |
brunofgc | 4:13ff9c81dc10 | 119 | //if(ED1 || ED2 || ED3 || ED4 || ED5 || ED6 || ED7 || ED8 || ED9){osDelay(25);} |
brunofgc | 4:13ff9c81dc10 | 120 | } |
brunofgc | 4:13ff9c81dc10 | 121 | |
brunofgc | 0:1c0a769988ee | 122 | void diversos::progressBar(uint32_t progresso,uint32_t total){ |
brunofgc | 0:1c0a769988ee | 123 | int i,j; |
brunofgc | 0:1c0a769988ee | 124 | char maxTam = 20; |
brunofgc | 0:1c0a769988ee | 125 | char engrenagem[4]={179,0x2F,0x2D,0x5C}; |
brunofgc | 0:1c0a769988ee | 126 | |
brunofgc | 0:1c0a769988ee | 127 | j=((double)progresso/(double)total)*maxTam; |
brunofgc | 0:1c0a769988ee | 128 | pc.printf("%c%c%c<",179,engrenagem[(unsigned int)progresso%4],179); |
brunofgc | 0:1c0a769988ee | 129 | for(i=0;i<maxTam;i++){ |
brunofgc | 0:1c0a769988ee | 130 | if(i<=j){ |
brunofgc | 0:1c0a769988ee | 131 | pc.printf("%c",178); |
brunofgc | 0:1c0a769988ee | 132 | }else{ |
brunofgc | 0:1c0a769988ee | 133 | pc.printf("%c",176); |
brunofgc | 0:1c0a769988ee | 134 | } |
brunofgc | 0:1c0a769988ee | 135 | } |
brunofgc | 0:1c0a769988ee | 136 | pc.printf("> %3.0f%% Progresso %5lu de %5lu\r ",((double)progresso/(double)total)*100,progresso,total); |
brunofgc | 0:1c0a769988ee | 137 | } |
brunofgc | 0:1c0a769988ee | 138 | |
brunofgc | 0:1c0a769988ee | 139 | void commands::exec(uint8_t idConnection){ |
brunofgc | 0:1c0a769988ee | 140 | char *ptr,*pCharFile,*ptrComando; |
brunofgc | 0:1c0a769988ee | 141 | char msg[100]; |
brunofgc | 0:1c0a769988ee | 142 | uint16_t currentCur,totalLengthCommands; |
brunofgc | 0:1c0a769988ee | 143 | static uint16_t fileCheckSum16BIT,checkSum16BIT_Lido; |
brunofgc | 0:1c0a769988ee | 144 | |
brunofgc | 0:1c0a769988ee | 145 | |
brunofgc | 0:1c0a769988ee | 146 | totalLengthCommands = strlen(commands::buffer); |
brunofgc | 0:1c0a769988ee | 147 | ptrComando = strtok(commands::buffer,";"); |
brunofgc | 0:1c0a769988ee | 148 | |
brunofgc | 0:1c0a769988ee | 149 | do{ |
brunofgc | 2:55b7b466e742 | 150 | |
brunofgc | 2:55b7b466e742 | 151 | |
brunofgc | 2:55b7b466e742 | 152 | |
brunofgc | 0:1c0a769988ee | 153 | ptr=strstr(ptrComando,"DELETE_SENT_FILES"); |
brunofgc | 0:1c0a769988ee | 154 | if(ptr) { |
brunofgc | 0:1c0a769988ee | 155 | pc.printf("Recebido comando para deletar arquivos enviados.\n"); |
brunofgc | 0:1c0a769988ee | 156 | sdCard::deleteSentFiles = true; |
brunofgc | 0:1c0a769988ee | 157 | } |
brunofgc | 0:1c0a769988ee | 158 | |
brunofgc | 0:1c0a769988ee | 159 | ptr=strstr(ptrComando,"SET_RTC:"); |
brunofgc | 0:1c0a769988ee | 160 | if(ptr) { |
brunofgc | 0:1c0a769988ee | 161 | ptr = strtok(ptr,":"); |
brunofgc | 0:1c0a769988ee | 162 | ptr = strtok(NULL,";"); |
brunofgc | 0:1c0a769988ee | 163 | set_time(atoi(ptr)); |
brunofgc | 0:1c0a769988ee | 164 | time_t seconds = time(NULL); |
brunofgc | 0:1c0a769988ee | 165 | pc.printf("Horario atualizado pelo server %s",ctime(&seconds)); |
brunofgc | 0:1c0a769988ee | 166 | } |
brunofgc | 0:1c0a769988ee | 167 | |
brunofgc | 0:1c0a769988ee | 168 | ptr=strstr(ptrComando,"sendArmazenamento"); |
brunofgc | 0:1c0a769988ee | 169 | if(ptr) { |
brunofgc | 0:1c0a769988ee | 170 | eventosRTC::rotina1hora=1; |
brunofgc | 0:1c0a769988ee | 171 | } |
brunofgc | 0:1c0a769988ee | 172 | |
brunofgc | 0:1c0a769988ee | 173 | ptr=strstr(ptrComando,"StartSendFile"); |
brunofgc | 0:1c0a769988ee | 174 | if(ptr){ |
brunofgc | 0:1c0a769988ee | 175 | modemCom::status.timeOut=100; |
brunofgc | 0:1c0a769988ee | 176 | strtok(ptr,",");//Descartando inicio |
brunofgc | 0:1c0a769988ee | 177 | pCharFile = strtok(NULL,",");//Selecionando nome do arquivo |
brunofgc | 0:1c0a769988ee | 178 | strcpy(sdCard::nomeArquivoEmRecebimento,pCharFile); |
brunofgc | 0:1c0a769988ee | 179 | pCharFile = strtok(NULL,";");//Selecionando string checkSum16BIT |
brunofgc | 0:1c0a769988ee | 180 | fileCheckSum16BIT = atoi(pCharFile); |
brunofgc | 0:1c0a769988ee | 181 | remove("/sd/RAD/tempFile.bin"); |
brunofgc | 0:1c0a769988ee | 182 | pc.printf("Iniciando recepcao do server arquivo deviceCfg.\n"); |
brunofgc | 0:1c0a769988ee | 183 | modemCom::status.recebendoArquivoDoServer = true; |
brunofgc | 0:1c0a769988ee | 184 | |
brunofgc | 0:1c0a769988ee | 185 | sprintf(modemCom::bufIn,"AT+CIPSEND=%u,%lu\r\n",idConnection,10); |
brunofgc | 0:1c0a769988ee | 186 | modem.puts(modemCom::bufIn); |
brunofgc | 0:1c0a769988ee | 187 | osDelay(100); |
brunofgc | 0:1c0a769988ee | 188 | modem.puts("sendData\r\n"); |
brunofgc | 0:1c0a769988ee | 189 | |
brunofgc | 0:1c0a769988ee | 190 | pc.printf("sendData\n"); |
brunofgc | 0:1c0a769988ee | 191 | modemCom::timeOutModem = 250; |
brunofgc | 0:1c0a769988ee | 192 | return; |
brunofgc | 0:1c0a769988ee | 193 | } |
brunofgc | 0:1c0a769988ee | 194 | |
brunofgc | 0:1c0a769988ee | 195 | ptr=strstr(ptrComando,"StopSendFile"); |
brunofgc | 0:1c0a769988ee | 196 | if(ptr){ |
brunofgc | 0:1c0a769988ee | 197 | pc.printf("Finalizando recepcao do server arquivo deviceCfg.\n"); |
brunofgc | 0:1c0a769988ee | 198 | modemCom::status.recebendoArquivoDoServer = false; |
brunofgc | 0:1c0a769988ee | 199 | checkSum16BIT_Lido = sdCard::calcCheckSum16BITFile("/sd/RAD/tempFile.bin"); |
brunofgc | 0:1c0a769988ee | 200 | if(fileCheckSum16BIT == checkSum16BIT_Lido){ |
brunofgc | 0:1c0a769988ee | 201 | if(sdCard::file_rename("/sd/RAD/tempFile.bin",sdCard::nomeArquivoEmRecebimento)){ |
brunofgc | 0:1c0a769988ee | 202 | /*sprintf(diversos::msg,"File Received checkSum16BIT_Lido <%lu>.\r\n",checkSum16BIT_Lido); |
brunofgc | 0:1c0a769988ee | 203 | modemCom::sendBufferCommandMode(2,diversos::msg,strlen(diversos::msg));*/ |
brunofgc | 0:1c0a769988ee | 204 | sprintf(msg,"File Received checkSum16BIT_Lido <%lu>.\r\n",checkSum16BIT_Lido); |
brunofgc | 0:1c0a769988ee | 205 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 0:1c0a769988ee | 206 | pc.printf("File Received checkSum16BIT_Lido <%lu>.\r\n",checkSum16BIT_Lido); |
brunofgc | 0:1c0a769988ee | 207 | |
brunofgc | 0:1c0a769988ee | 208 | if(strstr(sdCard::nomeArquivoEmRecebimento,"devices.cfg")!=NULL){ |
brunofgc | 0:1c0a769988ee | 209 | pc.printf("Excluindo arquivo armazenamento.txt .\r\n"); |
brunofgc | 0:1c0a769988ee | 210 | sdCard::excluiArquivo(&sdCard::armazenamento); |
brunofgc | 0:1c0a769988ee | 211 | pc.printf("Resetando o drome.\r\n"); |
brunofgc | 0:1c0a769988ee | 212 | hardwareReset=true; |
brunofgc | 0:1c0a769988ee | 213 | } |
brunofgc | 0:1c0a769988ee | 214 | |
brunofgc | 0:1c0a769988ee | 215 | }else{ |
brunofgc | 0:1c0a769988ee | 216 | //modemCom::sendBufferCommandMode(2,"FileCorrupted.\r\n",strlen("FileCorrupted.\r\n")); |
brunofgc | 4:13ff9c81dc10 | 217 | sprintf(msg,"erro"); |
brunofgc | 0:1c0a769988ee | 218 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 0:1c0a769988ee | 219 | pc.printf("Recebido correto mas n foi possivel renomear arquivo.\r\n"); |
brunofgc | 0:1c0a769988ee | 220 | } |
brunofgc | 0:1c0a769988ee | 221 | |
brunofgc | 0:1c0a769988ee | 222 | }else{ |
brunofgc | 0:1c0a769988ee | 223 | /*sprintf(diversos::msg,"File Corrupted checkSum16BIT_Lido <%lu>.\r\n",checkSum16BIT_Lido); |
brunofgc | 0:1c0a769988ee | 224 | modemCom::sendBufferCommandMode(2,diversos::msg,strlen(diversos::msg));*/ |
brunofgc | 0:1c0a769988ee | 225 | sprintf(msg,"File Corrupted checkSum16BIT_Lido <%lu>.\r\n",checkSum16BIT_Lido); |
brunofgc | 0:1c0a769988ee | 226 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 0:1c0a769988ee | 227 | pc.printf("File Corrupted checkSum16BIT_Lido <%lu>.\r\n",checkSum16BIT_Lido); |
brunofgc | 0:1c0a769988ee | 228 | } |
brunofgc | 0:1c0a769988ee | 229 | modemCom::status.timeOut=10; |
brunofgc | 0:1c0a769988ee | 230 | modemCom::timeOutModem = 50; |
brunofgc | 0:1c0a769988ee | 231 | } |
brunofgc | 0:1c0a769988ee | 232 | |
brunofgc | 0:1c0a769988ee | 233 | /*ptr=strstr(ptrComando,"requestFile,"); |
brunofgc | 0:1c0a769988ee | 234 | if(ptr){ |
brunofgc | 0:1c0a769988ee | 235 | FILE *fp; |
brunofgc | 0:1c0a769988ee | 236 | char c; |
brunofgc | 0:1c0a769988ee | 237 | strtok(ptr,","); |
brunofgc | 0:1c0a769988ee | 238 | pCharFile = strtok(NULL,";"); |
brunofgc | 0:1c0a769988ee | 239 | |
brunofgc | 0:1c0a769988ee | 240 | fp = fopen(pCharFile,"r"); |
brunofgc | 0:1c0a769988ee | 241 | if(fp!=NULL){ |
brunofgc | 0:1c0a769988ee | 242 | do{ |
brunofgc | 0:1c0a769988ee | 243 | c = fgetc(fp); |
brunofgc | 0:1c0a769988ee | 244 | if(!feof(fp)){modem.printf("%c",c);} |
brunofgc | 0:1c0a769988ee | 245 | modemCom::status.timeOut=10; |
brunofgc | 0:1c0a769988ee | 246 | }while(!feof(fp)); |
brunofgc | 0:1c0a769988ee | 247 | fclose(fp); |
brunofgc | 0:1c0a769988ee | 248 | }else{ |
brunofgc | 0:1c0a769988ee | 249 | modem.printf("Nao foi possivel abrir o arquivo.\n"); |
brunofgc | 0:1c0a769988ee | 250 | } |
brunofgc | 0:1c0a769988ee | 251 | }*/ |
brunofgc | 0:1c0a769988ee | 252 | |
brunofgc | 1:0e0967c88590 | 253 | ptr=strstr(ptrComando,"execAct:"); |
brunofgc | 1:0e0967c88590 | 254 | if(ptr){ |
brunofgc | 1:0e0967c88590 | 255 | char *pChar; |
brunofgc | 1:0e0967c88590 | 256 | uint32_t actId; |
brunofgc | 1:0e0967c88590 | 257 | pChar = strtok(ptr,":"); |
brunofgc | 1:0e0967c88590 | 258 | pChar = strtok(NULL,""); |
brunofgc | 1:0e0967c88590 | 259 | actId = atoi(pChar); |
brunofgc | 1:0e0967c88590 | 260 | if(dispositivos[0]->execAct(actId)){ |
brunofgc | 1:0e0967c88590 | 261 | sprintf(msg,"execAct_ack"); |
brunofgc | 1:0e0967c88590 | 262 | }else{ |
brunofgc | 1:0e0967c88590 | 263 | sprintf(msg,"execAct_nack"); |
brunofgc | 1:0e0967c88590 | 264 | } |
brunofgc | 1:0e0967c88590 | 265 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 1:0e0967c88590 | 266 | } |
brunofgc | 1:0e0967c88590 | 267 | |
brunofgc | 2:55b7b466e742 | 268 | if(strstr(ptr,"enviaDadosAoServer")){ |
brunofgc | 2:55b7b466e742 | 269 | eventosRTC::rotina15Minutos=true; |
brunofgc | 2:55b7b466e742 | 270 | sprintf(msg,"ack"); |
brunofgc | 2:55b7b466e742 | 271 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 2:55b7b466e742 | 272 | } |
brunofgc | 2:55b7b466e742 | 273 | |
brunofgc | 0:1c0a769988ee | 274 | ptr=strstr(ptrComando,"mbwrite:"); |
brunofgc | 0:1c0a769988ee | 275 | if(ptr){ |
brunofgc | 0:1c0a769988ee | 276 | uint8_t addr; |
brunofgc | 0:1c0a769988ee | 277 | uint16_t reg; |
brunofgc | 0:1c0a769988ee | 278 | uint32_t auxMod; |
brunofgc | 0:1c0a769988ee | 279 | char *pChar; |
brunofgc | 0:1c0a769988ee | 280 | |
brunofgc | 1:0e0967c88590 | 281 | //IR |
brunofgc | 1:0e0967c88590 | 282 | if(strstr(ptr,"IR,")){ |
brunofgc | 1:0e0967c88590 | 283 | uint8_t freq=38,porta=0; |
brunofgc | 1:0e0967c88590 | 284 | pChar = strtok(ptr,","); |
brunofgc | 1:0e0967c88590 | 285 | porta = atoi(strtok(NULL,",")); |
brunofgc | 1:0e0967c88590 | 286 | porta--; //Trazendo para índice 0; |
brunofgc | 1:0e0967c88590 | 287 | |
brunofgc | 1:0e0967c88590 | 288 | freq = atoi(strtok(NULL,",")); |
brunofgc | 1:0e0967c88590 | 289 | if(freq == 0){ |
brunofgc | 1:0e0967c88590 | 290 | //Se não tiver frequência, ponha 38. |
brunofgc | 1:0e0967c88590 | 291 | freq = 38; |
brunofgc | 1:0e0967c88590 | 292 | } |
brunofgc | 1:0e0967c88590 | 293 | |
brunofgc | 2:55b7b466e742 | 294 | pChar = strtok(NULL,"S");//Reaproveitando variável pTipoComando |
brunofgc | 2:55b7b466e742 | 295 | |
brunofgc | 1:0e0967c88590 | 296 | deserializaPacoteIR(pChar); |
brunofgc | 1:0e0967c88590 | 297 | enviaComandoIR(freq,porta); |
brunofgc | 1:0e0967c88590 | 298 | sprintf(msg,"WriteIR_ack"); |
brunofgc | 1:0e0967c88590 | 299 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 1:0e0967c88590 | 300 | } |
brunofgc | 1:0e0967c88590 | 301 | |
brunofgc | 0:1c0a769988ee | 302 | //Float |
brunofgc | 0:1c0a769988ee | 303 | if(strstr(ptr,"float,")){ |
brunofgc | 0:1c0a769988ee | 304 | float v_float; |
brunofgc | 0:1c0a769988ee | 305 | |
brunofgc | 0:1c0a769988ee | 306 | //Capturando parametros comuns |
brunofgc | 0:1c0a769988ee | 307 | pChar = strtok(ptr,","); |
brunofgc | 0:1c0a769988ee | 308 | |
brunofgc | 0:1c0a769988ee | 309 | //Parametro 1 |
brunofgc | 0:1c0a769988ee | 310 | pChar = strtok(NULL,","); |
brunofgc | 0:1c0a769988ee | 311 | addr = atoi(pChar); |
brunofgc | 0:1c0a769988ee | 312 | |
brunofgc | 0:1c0a769988ee | 313 | //Parametro 2 |
brunofgc | 0:1c0a769988ee | 314 | pChar = strtok(NULL,","); |
brunofgc | 0:1c0a769988ee | 315 | reg = atoi(pChar); |
brunofgc | 0:1c0a769988ee | 316 | |
brunofgc | 0:1c0a769988ee | 317 | //Parametro 3 |
brunofgc | 0:1c0a769988ee | 318 | pChar = strtok(NULL,","); |
brunofgc | 0:1c0a769988ee | 319 | //v_float = diversos::stringToFloat(pChar,50); |
brunofgc | 0:1c0a769988ee | 320 | v_float = atof(pChar); |
brunofgc | 1:0e0967c88590 | 321 | |
brunofgc | 1:0e0967c88590 | 322 | //Envio o dado via Modbus |
brunofgc | 1:0e0967c88590 | 323 | if(!modBusMaster1::writeFloat(addr,reg,1,&v_float)){ |
brunofgc | 1:0e0967c88590 | 324 | pc.printf("Valor <%f> escrito no registrador %lu do endereco modbus %u.\n",v_float,reg,addr); |
brunofgc | 0:1c0a769988ee | 325 | /*sprintf(diversos::msg,"WriteFloat_ack"); |
brunofgc | 0:1c0a769988ee | 326 | modemCom::sendBufferCommandMode(2,diversos::msg,strlen(diversos::msg));*/ |
brunofgc | 0:1c0a769988ee | 327 | |
brunofgc | 1:0e0967c88590 | 328 | sprintf(msg,"WriteFloat_ack"); |
brunofgc | 1:0e0967c88590 | 329 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 1:0e0967c88590 | 330 | }else{ |
brunofgc | 1:0e0967c88590 | 331 | pc.printf("Erro ao escrever valor <%f> no registrador %lu do endereco modbus %u.\n",v_float,reg,addr); |
brunofgc | 1:0e0967c88590 | 332 | /*sprintf(diversos::msg,"WriteFloat_nack"); |
brunofgc | 1:0e0967c88590 | 333 | modemCom::sendBufferCommandMode(2,diversos::msg,strlen(diversos::msg));*/ |
brunofgc | 1:0e0967c88590 | 334 | |
brunofgc | 1:0e0967c88590 | 335 | sprintf(msg,"WriteFloat_nack"); |
brunofgc | 0:1c0a769988ee | 336 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 1:0e0967c88590 | 337 | } |
brunofgc | 1:0e0967c88590 | 338 | } |
brunofgc | 1:0e0967c88590 | 339 | |
brunofgc | 1:0e0967c88590 | 340 | //PWM |
brunofgc | 1:0e0967c88590 | 341 | if(strstr(ptr,"PWM,")){ |
brunofgc | 1:0e0967c88590 | 342 | float v_float; |
brunofgc | 1:0e0967c88590 | 343 | |
brunofgc | 1:0e0967c88590 | 344 | //Capturando parametros comuns |
brunofgc | 1:0e0967c88590 | 345 | pChar = strtok(ptr,","); |
brunofgc | 1:0e0967c88590 | 346 | |
brunofgc | 1:0e0967c88590 | 347 | //Parametro 1 |
brunofgc | 1:0e0967c88590 | 348 | pChar = strtok(NULL,","); |
brunofgc | 1:0e0967c88590 | 349 | addr = atoi(pChar); |
brunofgc | 1:0e0967c88590 | 350 | |
brunofgc | 1:0e0967c88590 | 351 | //Parametro 2 |
brunofgc | 1:0e0967c88590 | 352 | pChar = strtok(NULL,","); |
brunofgc | 1:0e0967c88590 | 353 | reg = atoi(pChar); |
brunofgc | 1:0e0967c88590 | 354 | |
brunofgc | 1:0e0967c88590 | 355 | //Parametro 3 |
brunofgc | 1:0e0967c88590 | 356 | pChar = strtok(NULL,","); |
brunofgc | 1:0e0967c88590 | 357 | //v_float = diversos::stringToFloat(pChar,50); |
brunofgc | 1:0e0967c88590 | 358 | v_float = atof(pChar); |
brunofgc | 1:0e0967c88590 | 359 | |
brunofgc | 1:0e0967c88590 | 360 | pc.printf("\r\n\r\nVerificando conteudo de pChar antes de converter para float <%s>.\r\n",pChar); |
brunofgc | 1:0e0967c88590 | 361 | |
brunofgc | 1:0e0967c88590 | 362 | //Retirando a parte inteira referente ao periodo em us do pwm |
brunofgc | 1:0e0967c88590 | 363 | |
brunofgc | 1:0e0967c88590 | 364 | auxMod = v_float/10; |
brunofgc | 1:0e0967c88590 | 365 | v_float = v_float-(auxMod*10); |
brunofgc | 1:0e0967c88590 | 366 | SD1.period_us(auxMod); |
brunofgc | 1:0e0967c88590 | 367 | pwmPeriod = auxMod; |
brunofgc | 1:0e0967c88590 | 368 | switch(reg){ |
brunofgc | 1:0e0967c88590 | 369 | case 0: |
brunofgc | 1:0e0967c88590 | 370 | SD1.write(v_float); |
brunofgc | 1:0e0967c88590 | 371 | break; |
brunofgc | 1:0e0967c88590 | 372 | case 1: |
brunofgc | 1:0e0967c88590 | 373 | SD2.write(v_float); |
brunofgc | 1:0e0967c88590 | 374 | break; |
brunofgc | 1:0e0967c88590 | 375 | case 2: |
brunofgc | 1:0e0967c88590 | 376 | SD3.write(v_float); |
brunofgc | 1:0e0967c88590 | 377 | break; |
brunofgc | 1:0e0967c88590 | 378 | case 3: |
brunofgc | 1:0e0967c88590 | 379 | SD4.write(v_float); |
brunofgc | 1:0e0967c88590 | 380 | break; |
brunofgc | 1:0e0967c88590 | 381 | case 4: |
brunofgc | 1:0e0967c88590 | 382 | SD5.write(v_float); |
brunofgc | 1:0e0967c88590 | 383 | break; |
brunofgc | 1:0e0967c88590 | 384 | case 5: |
brunofgc | 1:0e0967c88590 | 385 | SD6.write(v_float); |
brunofgc | 1:0e0967c88590 | 386 | break; |
brunofgc | 0:1c0a769988ee | 387 | } |
brunofgc | 1:0e0967c88590 | 388 | pc.printf("Valor puro %f, %lu escrito como periodo e %f como duty no reg %u.\n",v_float,auxMod,v_float,reg); |
brunofgc | 1:0e0967c88590 | 389 | /*sprintf(diversos::msg,"WriteFloat_ack"); |
brunofgc | 1:0e0967c88590 | 390 | modemCom::sendBufferCommandMode(2,diversos::msg,strlen(diversos::msg));*/ |
brunofgc | 1:0e0967c88590 | 391 | |
brunofgc | 1:0e0967c88590 | 392 | sprintf(msg,"WritePWM_ack"); |
brunofgc | 1:0e0967c88590 | 393 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 0:1c0a769988ee | 394 | } |
brunofgc | 0:1c0a769988ee | 395 | |
brunofgc | 0:1c0a769988ee | 396 | //uint32_t |
brunofgc | 0:1c0a769988ee | 397 | if(strstr(ptr,"uint32_t,")){ |
brunofgc | 0:1c0a769988ee | 398 | uint32_t v_uint32_t; |
brunofgc | 0:1c0a769988ee | 399 | |
brunofgc | 0:1c0a769988ee | 400 | //Capturando parametros comuns |
brunofgc | 0:1c0a769988ee | 401 | pChar = strtok(ptr,","); |
brunofgc | 0:1c0a769988ee | 402 | |
brunofgc | 0:1c0a769988ee | 403 | //Parametro 1 |
brunofgc | 0:1c0a769988ee | 404 | pChar = strtok(NULL,","); |
brunofgc | 0:1c0a769988ee | 405 | addr = atoi(pChar); |
brunofgc | 0:1c0a769988ee | 406 | |
brunofgc | 0:1c0a769988ee | 407 | //Parametro 2 |
brunofgc | 0:1c0a769988ee | 408 | pChar = strtok(NULL,","); |
brunofgc | 0:1c0a769988ee | 409 | reg = atoi(pChar); |
brunofgc | 0:1c0a769988ee | 410 | |
brunofgc | 0:1c0a769988ee | 411 | //Parametro 3 |
brunofgc | 0:1c0a769988ee | 412 | pChar = strtok(NULL,","); |
brunofgc | 0:1c0a769988ee | 413 | v_uint32_t = atoi(pChar); |
brunofgc | 0:1c0a769988ee | 414 | |
brunofgc | 0:1c0a769988ee | 415 | if(!modBusMaster1::writeRegister32BIT(addr,reg,1,&v_uint32_t)){ |
brunofgc | 0:1c0a769988ee | 416 | pc.printf("Valor <%lu> escrito no registrador %lu do endereco modbus %u.\n",v_uint32_t,reg,addr); |
brunofgc | 0:1c0a769988ee | 417 | /*sprintf(diversos::msg,"Write_uint32_t_ack"); |
brunofgc | 0:1c0a769988ee | 418 | modemCom::sendBufferCommandMode(2,diversos::msg,strlen(diversos::msg));*/ |
brunofgc | 0:1c0a769988ee | 419 | |
brunofgc | 1:0e0967c88590 | 420 | sprintf(msg,"Write_uint32_t_ack"); |
brunofgc | 0:1c0a769988ee | 421 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 0:1c0a769988ee | 422 | }else{ |
brunofgc | 0:1c0a769988ee | 423 | pc.printf("Erro ao escrever valor <%lu> no registrador %lu do endereco modbus %u.\n",v_uint32_t,reg,addr); |
brunofgc | 0:1c0a769988ee | 424 | /*sprintf(diversos::msg,"Write_uint32_t_nack"); |
brunofgc | 0:1c0a769988ee | 425 | modemCom::sendBufferCommandMode(2,diversos::msg,strlen(diversos::msg));*/ |
brunofgc | 0:1c0a769988ee | 426 | |
brunofgc | 1:0e0967c88590 | 427 | sprintf(msg,"Write_uint32_t_nack"); |
brunofgc | 0:1c0a769988ee | 428 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 0:1c0a769988ee | 429 | } |
brunofgc | 0:1c0a769988ee | 430 | } |
brunofgc | 0:1c0a769988ee | 431 | |
brunofgc | 0:1c0a769988ee | 432 | //uint16_t |
brunofgc | 0:1c0a769988ee | 433 | if(strstr(ptr,"uint16_t,")){ |
brunofgc | 0:1c0a769988ee | 434 | uint16_t v_uint16_t; |
brunofgc | 0:1c0a769988ee | 435 | |
brunofgc | 0:1c0a769988ee | 436 | //Capturando parametros comuns |
brunofgc | 0:1c0a769988ee | 437 | pChar = strtok(ptr,","); |
brunofgc | 0:1c0a769988ee | 438 | |
brunofgc | 0:1c0a769988ee | 439 | //Parametro 1 |
brunofgc | 0:1c0a769988ee | 440 | pChar = strtok(NULL,","); |
brunofgc | 0:1c0a769988ee | 441 | addr = atoi(pChar); |
brunofgc | 0:1c0a769988ee | 442 | |
brunofgc | 0:1c0a769988ee | 443 | //Parametro 2 |
brunofgc | 0:1c0a769988ee | 444 | pChar = strtok(NULL,","); |
brunofgc | 0:1c0a769988ee | 445 | reg = atoi(pChar); |
brunofgc | 0:1c0a769988ee | 446 | |
brunofgc | 0:1c0a769988ee | 447 | //Parametro 3 |
brunofgc | 0:1c0a769988ee | 448 | pChar = strtok(NULL,","); |
brunofgc | 0:1c0a769988ee | 449 | v_uint16_t = atoi(pChar); |
brunofgc | 0:1c0a769988ee | 450 | |
brunofgc | 0:1c0a769988ee | 451 | if(!modBusMaster1::writeRegister16BIT(addr,reg,1,&v_uint16_t)){ |
brunofgc | 0:1c0a769988ee | 452 | pc.printf("Valor <%lu> escrito no registrador %lu do endereco modbus %u.\n",v_uint16_t,reg,addr); |
brunofgc | 0:1c0a769988ee | 453 | /*sprintf(diversos::msg,"Write_uint16_t_ack"); |
brunofgc | 0:1c0a769988ee | 454 | modemCom::sendBufferCommandMode(2,diversos::msg,strlen(diversos::msg));*/ |
brunofgc | 0:1c0a769988ee | 455 | |
brunofgc | 1:0e0967c88590 | 456 | sprintf(msg,"Write_uint16_t_ack"); |
brunofgc | 0:1c0a769988ee | 457 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 0:1c0a769988ee | 458 | }else{ |
brunofgc | 0:1c0a769988ee | 459 | pc.printf("Erro ao escrever valor <%lu> no registrador %lu do endereco modbus %u.\n",v_uint16_t,reg,addr); |
brunofgc | 0:1c0a769988ee | 460 | /*sprintf(diversos::msg,"Write_uint16_t_nack"); |
brunofgc | 0:1c0a769988ee | 461 | modemCom::sendBufferCommandMode(2,diversos::msg,strlen(diversos::msg)); */ |
brunofgc | 0:1c0a769988ee | 462 | |
brunofgc | 1:0e0967c88590 | 463 | sprintf(msg,"Write_uint16_t_nack"); |
brunofgc | 0:1c0a769988ee | 464 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 0:1c0a769988ee | 465 | } |
brunofgc | 0:1c0a769988ee | 466 | } |
brunofgc | 0:1c0a769988ee | 467 | |
brunofgc | 0:1c0a769988ee | 468 | //bit |
brunofgc | 0:1c0a769988ee | 469 | if(strstr(ptr,"bit,")){ |
brunofgc | 0:1c0a769988ee | 470 | bool v_bool; |
brunofgc | 0:1c0a769988ee | 471 | |
brunofgc | 0:1c0a769988ee | 472 | //Capturando parametros comuns |
brunofgc | 0:1c0a769988ee | 473 | pChar = strtok(ptr,","); |
brunofgc | 0:1c0a769988ee | 474 | |
brunofgc | 0:1c0a769988ee | 475 | //Parametro 1 |
brunofgc | 0:1c0a769988ee | 476 | pChar = strtok(NULL,","); |
brunofgc | 0:1c0a769988ee | 477 | addr = atoi(pChar); |
brunofgc | 0:1c0a769988ee | 478 | |
brunofgc | 0:1c0a769988ee | 479 | //Parametro 2 |
brunofgc | 0:1c0a769988ee | 480 | pChar = strtok(NULL,","); |
brunofgc | 0:1c0a769988ee | 481 | reg = atoi(pChar); |
brunofgc | 0:1c0a769988ee | 482 | |
brunofgc | 0:1c0a769988ee | 483 | //Parametro 3 |
brunofgc | 0:1c0a769988ee | 484 | pChar = strtok(NULL,","); |
brunofgc | 0:1c0a769988ee | 485 | v_bool = (atoi(pChar) > 0); |
brunofgc | 0:1c0a769988ee | 486 | |
brunofgc | 0:1c0a769988ee | 487 | if(addr != 254){ |
brunofgc | 0:1c0a769988ee | 488 | //writeSingleCoil(uint8_t,uint16_t,bool); //Endereço slave, registrador, bool |
brunofgc | 0:1c0a769988ee | 489 | if(!modBusMaster1::writeSingleCoil(addr,reg,v_bool)){ |
brunofgc | 0:1c0a769988ee | 490 | pc.printf("Valor <%u> escrito no registrador %lu do endereco modbus %u.\n",v_bool,reg,addr); |
brunofgc | 0:1c0a769988ee | 491 | /*sprintf(diversos::msg,"Write_bool_ack"); |
brunofgc | 0:1c0a769988ee | 492 | modemCom::sendBufferCommandMode(2,diversos::msg,strlen(diversos::msg));*/ |
brunofgc | 0:1c0a769988ee | 493 | |
brunofgc | 1:0e0967c88590 | 494 | sprintf(msg,"Write_bool_ack"); |
brunofgc | 0:1c0a769988ee | 495 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 0:1c0a769988ee | 496 | }else{ |
brunofgc | 0:1c0a769988ee | 497 | pc.printf("Erro ao escrever valor <%u> no registrador %lu do endereco modbus %u.\n",v_bool,reg,addr); |
brunofgc | 0:1c0a769988ee | 498 | /*sprintf(diversos::msg,"Write_bool_nack"); |
brunofgc | 0:1c0a769988ee | 499 | modemCom::sendBufferCommandMode(2,diversos::msg,strlen(diversos::msg));*/ |
brunofgc | 0:1c0a769988ee | 500 | |
brunofgc | 1:0e0967c88590 | 501 | sprintf(msg,"Write_bool_nack"); |
brunofgc | 0:1c0a769988ee | 502 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 0:1c0a769988ee | 503 | } |
brunofgc | 0:1c0a769988ee | 504 | }else{ |
brunofgc | 0:1c0a769988ee | 505 | switch(reg){ |
brunofgc | 0:1c0a769988ee | 506 | case 0: |
brunofgc | 0:1c0a769988ee | 507 | SD1.write(v_bool*1.0f); |
brunofgc | 0:1c0a769988ee | 508 | break; |
brunofgc | 0:1c0a769988ee | 509 | case 1: |
brunofgc | 0:1c0a769988ee | 510 | SD2.write(v_bool*1.0f); |
brunofgc | 0:1c0a769988ee | 511 | break; |
brunofgc | 0:1c0a769988ee | 512 | case 2: |
brunofgc | 0:1c0a769988ee | 513 | SD3.write(v_bool*1.0f); |
brunofgc | 0:1c0a769988ee | 514 | break; |
brunofgc | 0:1c0a769988ee | 515 | case 3: |
brunofgc | 0:1c0a769988ee | 516 | SD4.write(v_bool*1.0f); |
brunofgc | 0:1c0a769988ee | 517 | break; |
brunofgc | 0:1c0a769988ee | 518 | case 4: |
brunofgc | 0:1c0a769988ee | 519 | SD5.write(v_bool*1.0f); |
brunofgc | 0:1c0a769988ee | 520 | break; |
brunofgc | 0:1c0a769988ee | 521 | case 5: |
brunofgc | 0:1c0a769988ee | 522 | SD6.write(v_bool*1.0f); |
brunofgc | 0:1c0a769988ee | 523 | break; |
brunofgc | 0:1c0a769988ee | 524 | case 6: |
brunofgc | 0:1c0a769988ee | 525 | SD7 = v_bool; |
brunofgc | 0:1c0a769988ee | 526 | break; |
brunofgc | 0:1c0a769988ee | 527 | case 7: |
brunofgc | 0:1c0a769988ee | 528 | SD8 = v_bool; |
brunofgc | 0:1c0a769988ee | 529 | break; |
brunofgc | 0:1c0a769988ee | 530 | } |
brunofgc | 0:1c0a769988ee | 531 | pc.printf("Valor <%u> escrito no registrador %lu do endereco modbus %u.\n",v_bool,reg,addr); |
brunofgc | 0:1c0a769988ee | 532 | /*sprintf(diversos::msg,"Write_bool_ack"); |
brunofgc | 0:1c0a769988ee | 533 | modemCom::sendBufferCommandMode(2,diversos::msg,strlen(diversos::msg));*/ |
brunofgc | 0:1c0a769988ee | 534 | |
brunofgc | 1:0e0967c88590 | 535 | sprintf(msg,"Write_bool_ack"); |
brunofgc | 0:1c0a769988ee | 536 | modemCom::sendBufferCommandMode(idConnection,msg,strlen(msg)); |
brunofgc | 0:1c0a769988ee | 537 | } |
brunofgc | 0:1c0a769988ee | 538 | } |
brunofgc | 0:1c0a769988ee | 539 | modemCom::status.timeOut=10; |
brunofgc | 0:1c0a769988ee | 540 | } |
brunofgc | 0:1c0a769988ee | 541 | |
brunofgc | 0:1c0a769988ee | 542 | currentCur = strlen(ptrComando) + 1; //Aqui eu pego onde devo buscar novamente mais algum comando. |
brunofgc | 0:1c0a769988ee | 543 | if(currentCur>=totalLengthCommands){ |
brunofgc | 0:1c0a769988ee | 544 | //modemCom::status.timeOut=10; |
brunofgc | 0:1c0a769988ee | 545 | ptrComando = NULL; |
brunofgc | 0:1c0a769988ee | 546 | }else{ |
brunofgc | 0:1c0a769988ee | 547 | ptrComando = strtok(&ptrComando[currentCur],";"); |
brunofgc | 0:1c0a769988ee | 548 | } |
brunofgc | 0:1c0a769988ee | 549 | }while(ptrComando != NULL);//Este loop executa cada instrução. |
brunofgc | 0:1c0a769988ee | 550 | pc.printf("Atendidos todos os comandos.\n"); |
brunofgc | 0:1c0a769988ee | 551 | } |