Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DS1820 HighSpeedAnalogIn devices mbed
Revision 14:c0162ab2a951, committed 2017-11-09
- Comitter:
- brunofgc
- Date:
- Thu Nov 09 12:53:41 2017 +0000
- Parent:
- 13:b9183b4bc049
- Child:
- 15:0f78bf9c13ec
- Commit message:
- vers?o com bootloader
Changed in this revision
--- a/devices.lib Mon Oct 23 15:35:18 2017 +0000 +++ b/devices.lib Thu Nov 09 12:53:41 2017 +0000 @@ -1,1 +1,1 @@ -devices#0230ec4d2e68 +devices#b61bb770f7b2
--- a/diversos.cpp Mon Oct 23 15:35:18 2017 +0000
+++ b/diversos.cpp Thu Nov 09 12:53:41 2017 +0000
@@ -153,6 +153,7 @@
if(ptr){
modemCom::status.timeOut=100;
sdCard::nBytesArquivoRecebidos = 0;
+ sdCard::checkSum = 0;
strtok(ptr,",");//Descartando inicio
pCharFile = strtok(NULL,",");//Selecionando nome do arquivo
strcpy(sdCard::nomeArquivoEmRecebimento,pCharFile);
@@ -174,8 +175,9 @@
ptr=strstr(ptrComando,"StopSendFile");
if(ptr){
- pc.printf("Finalizando recepcao de arquivo.\n");
- checkSum16BIT_Lido = sdCard::calcCheckSum16BITFile("/sd/RAD/tempFile.bin");
+ pc.printf("Finalizando recepcao de arquivo.\n");
+ checkSum16BIT_Lido = sdCard::checkSum;//sdCard::calcCheckSum16BITFile("/sd/RAD/tempFile.bin");
+ pc.printf("Feito o calculo de CRC = %lu.\n",checkSum16BIT_Lido);
if(fileCheckSum16BIT == checkSum16BIT_Lido){
if(sdCard::file_rename("/sd/RAD/tempFile.bin",sdCard::nomeArquivoEmRecebimento)){
/*sprintf(diversos::msg,"File Received checkSum16BIT_Lido <%lu>.\r\n",checkSum16BIT_Lido);
@@ -191,6 +193,7 @@
}
if(strstr(sdCard::nomeArquivoEmRecebimento,"firmware.bin")!=NULL){
+ pc.printf("Chamando bootloader.\r\n");
callBootLoader = true;
}
}else{
--- a/funcoesSDCard.cpp Mon Oct 23 15:35:18 2017 +0000
+++ b/funcoesSDCard.cpp Thu Nov 09 12:53:41 2017 +0000
@@ -13,6 +13,7 @@
uint32_t sdCard::nBytesArquivoRecebidos;
uint8_t sdCard::currentBank;
uint8_t sdCard::currentBankSending;
+uint16_t sdCard::checkSum;
bool sdCard::arquivosAbertos=false;
char sdCard::nomeArquivoEmRecebimento[30];
@@ -186,6 +187,9 @@
for(i=0;i<tam;i++){
//fprintf(arquivo->fp,"%c",data[i]);
+
+ sdCard::checkSum+=data[i];
+
fputc(data[i],arquivo->fp);
fflush(arquivo->fp);
}
@@ -222,6 +226,8 @@
hex[0]=data[i];
hex[1]=data[i+1];
c = hextobin(hex,2);
+
+ sdCard::checkSum+=c;
fputc(c,arquivo->fp);
fflush(arquivo->fp);
@@ -437,7 +443,18 @@
uint8_t sdCard::file_rename(const char *oldfname, const char *newfname) {
- //rename(oldfname,newfname);
+ /*if(remove(oldfname)<0){
+ pc.printf("file_rename 1.\r\n");
+ return 0;
+ }
+ if(rename(oldfname,newfname)<0){
+ pc.printf("file_rename 2.\r\n");
+ return 0;
+ }else{
+ pc.printf("file_rename 3.\r\n");
+ return 1;
+ }*/
+
#define maxTamFileCopy 128
char bufCopy[maxTamFileCopy];
uint8_t retval = 0;
@@ -503,5 +520,7 @@
}
sdCard::arquivosAbertos=false;
pc.printf("file_rename retval <%lu>.\r\n",retval);
+
return (retval);
+
}
--- a/funcoesSDCard.h Mon Oct 23 15:35:18 2017 +0000 +++ b/funcoesSDCard.h Thu Nov 09 12:53:41 2017 +0000 @@ -28,6 +28,7 @@ extern char nomeArquivoEmRecebimento[30]; extern uint8_t currentBank; extern uint8_t currentBankSending; + extern uint16_t checkSum; int init();
--- a/main.cpp Mon Oct 23 15:35:18 2017 +0000
+++ b/main.cpp Thu Nov 09 12:53:41 2017 +0000
@@ -59,7 +59,7 @@
uint16_t aiFiltrada[4];
bool entradasDigitais[9];
-CircularBuffer bufModem(maxBufInModem);
+CircularBuffer bufModem(maxBufInModem) __attribute__ ((section("AHBSRAM0")));
CircularBuffer bufPC(128);
CircularBuffer sdCardBuf(1024);
@@ -317,19 +317,19 @@
}
void inicializaMaquina(){
- pwmPeriod = 100000;
+ pwmPeriod = 100000;
SD1.period_us(pwmPeriod);
modemCom::atendendoWebServer = false;
- serialPC::serialPC_init();
- pc.printf("Versao atualizada pela internet BSoares acompanhando 23/10/2017.\r\n");
+ serialPC::serialPC_init();
+ pc.printf("Versao 24/10/2017.\r\n");
modemCom::timeOutModem = 30;
- serialModem::serial_init();
- numeroDeBytesPorEnvio = 768;
- modBusMaster1::modBusMaster(&modBusMaster1Serial,19200,&max_de);
- inicializaSensoresTemperatura();
+ serialModem::serial_init();
+ numeroDeBytesPorEnvio = 768;
+ modBusMaster1::modBusMaster(&modBusMaster1Serial,19200,&max_de);
+ inicializaSensoresTemperatura();
if(sdCard::init()){
- pc.printf("SD Card inicializado com sucesso.\n");
+ pc.printf("SD Card inicializado com sucesso.\n");
//Carregando a lista de dispositivos
loadDevices();
}else{
--- a/modbusMaster1.h Mon Oct 23 15:35:18 2017 +0000
+++ b/modbusMaster1.h Thu Nov 09 12:53:41 2017 +0000
@@ -6,7 +6,7 @@
#define maxLenBufModBus 850
-//#define modbusDebug
+#define modbusDebug
namespace modBusMaster1{
extern Serial *serModBus;
--- a/modem.cpp Mon Oct 23 15:35:18 2017 +0000
+++ b/modem.cpp Thu Nov 09 12:53:41 2017 +0000
@@ -862,7 +862,7 @@
modemCom::status.modemResponse=true;
- //pc.printf("Vem do modem <%s>.\r\n",modemCom::bufIn);
+ pc.printf("Vem do modem <%s>.\r\n",modemCom::bufIn);
//Reconhecimento dos status
modemCom::status.PROMPT_ENVIO_COMMAND_MODE=0;
@@ -962,6 +962,7 @@
if(IPDNumBytes && modemCom::status.recebendoArquivoDoServer && (strstr(modemCom::bufIn,"CONNECT")==NULL) && (strstr(modemCom::bufIn,"*ServerCommand*")==NULL) ){
sdCard::insereDadosArquivoHex(&sdCard::tempFile,modemCom::bufIn,IPDNumBytes);
+ //sdCard::insereDadosArquivo(&sdCard::tempFile,modemCom::bufIn,IPDNumBytes);
sdCard::nBytesArquivoRecebidos+=IPDNumBytes;
bufModem.del();
sprintf(modemCom::bufIn,"AT+CIPSEND=%u,%lu\r\n",connID,10);
--- a/modem.h Mon Oct 23 15:35:18 2017 +0000
+++ b/modem.h Thu Nov 09 12:53:41 2017 +0000
@@ -71,13 +71,10 @@
namespace modemCom{
extern modemStatus status; //Struct que comporta os status do modem
- extern char* bufIn; //Ponteiro para buffer de entrada do modem;
+ extern char* bufIn; //Ponteiro para buffer de entrada do modem;
extern uint32_t timeOutModem;
extern bool exibeEntradaPacote;
- extern bool atendendoWebServer;
-
-
-
+ extern bool atendendoWebServer;
//Funções
uint8_t sendToModem(char *,uint8_t,char *,char *,uint16_t,uint8_t,uint16_t); //Função que envia strings ao modem
void processaPacote(void const *); //Função que processa pacotes entrantes do modem
--- a/serialModem.h Mon Oct 23 15:35:18 2017 +0000
+++ b/serialModem.h Thu Nov 09 12:53:41 2017 +0000
@@ -1,15 +1,14 @@
#include "mbed.h"
#include "cmsis_os.h" //Nucleo do Real Time Operational System
#include "main.h" //Funções e variáveis globais
-#define maxBufInModem 1024
+#define maxBufInModem 1900
#define maxBufOutModem 512
namespace serialModem{
//variáveis
extern osTimerId timer_pacote; //ticker timer (Timer recursivo ISR) que processa pacotes entrantes da serial PC.
extern bool startTimer_pacote;
- extern bool processarPacote;
-
+ extern bool processarPacote;
//funções
void serial_init(); //Função que faz a inicialização do recurso serial uart modem