move message buffers to heap to avoid stack overflows
This commit is contained in:
parent
57c43c50a7
commit
368f8e50ed
10
src/main.cpp
10
src/main.cpp
|
@ -35,6 +35,7 @@ const unsigned long HEAP_REPORT_TIME=2000; //set to 0 to disable heap reporting
|
||||||
#include <ESPAsyncWebServer.h>
|
#include <ESPAsyncWebServer.h>
|
||||||
#include <Preferences.h>
|
#include <Preferences.h>
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
|
#include <memory>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "esp_heap_caps.h"
|
#include "esp_heap_caps.h"
|
||||||
|
@ -176,7 +177,8 @@ void handleN2kMessage(const tN2kMsg &n2kMsg,int sourceId, bool isConverted=false
|
||||||
if (sourceId == N2K_CHANNEL_ID){
|
if (sourceId == N2K_CHANNEL_ID){
|
||||||
countNMEA2KIn.add(n2kMsg.PGN);
|
countNMEA2KIn.add(n2kMsg.PGN);
|
||||||
}
|
}
|
||||||
char buf[MAX_NMEA2000_MESSAGE_SEASMART_SIZE];
|
char *buf=new char[MAX_NMEA2000_MESSAGE_SEASMART_SIZE];
|
||||||
|
std::unique_ptr<char> bufDel(buf);
|
||||||
bool messageCreated=false;
|
bool messageCreated=false;
|
||||||
channels.allChannels([&](GwChannel *c){
|
channels.allChannels([&](GwChannel *c){
|
||||||
if (c->sendSeaSmart()){
|
if (c->sendSeaSmart()){
|
||||||
|
@ -207,7 +209,8 @@ void handleN2kMessage(const tN2kMsg &n2kMsg,int sourceId, bool isConverted=false
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
void SendNMEA0183Message(const tNMEA0183Msg &NMEA0183Msg, int sourceId,bool convert=false) {
|
void SendNMEA0183Message(const tNMEA0183Msg &NMEA0183Msg, int sourceId,bool convert=false) {
|
||||||
logger.logDebug(GwLog::DEBUG+2,"SendNMEA0183(1)");
|
logger.logDebug(GwLog::DEBUG+2,"SendNMEA0183(1)");
|
||||||
char buf[MAX_NMEA0183_MESSAGE_SIZE+3];
|
char *buf=new char[MAX_NMEA0183_MESSAGE_SIZE+3];
|
||||||
|
std::unique_ptr<char> bufDel(buf);
|
||||||
if ( !NMEA0183Msg.GetMessage(buf, MAX_NMEA0183_MESSAGE_SIZE) ) return;
|
if ( !NMEA0183Msg.GetMessage(buf, MAX_NMEA0183_MESSAGE_SIZE) ) return;
|
||||||
logger.logDebug(GwLog::DEBUG+2,"SendNMEA0183: %s",buf);
|
logger.logDebug(GwLog::DEBUG+2,"SendNMEA0183: %s",buf);
|
||||||
if (convert){
|
if (convert){
|
||||||
|
@ -554,7 +557,8 @@ protected:
|
||||||
tNMEA0183Msg msg;
|
tNMEA0183Msg msg;
|
||||||
msg.Init("XDR",config.getString(config.talkerId,String("GP")).c_str());
|
msg.Init("XDR",config.getString(config.talkerId,String("GP")).c_str());
|
||||||
msg.AddStrField(val.c_str());
|
msg.AddStrField(val.c_str());
|
||||||
char buf[MAX_NMEA0183_MSG_BUF_LEN];
|
char *buf=new char[MAX_NMEA0183_MSG_BUF_LEN+2];
|
||||||
|
std::unique_ptr<char> bufDel(buf);
|
||||||
msg.GetMessage(buf,MAX_NMEA0183_MSG_BUF_LEN);
|
msg.GetMessage(buf,MAX_NMEA0183_MSG_BUF_LEN);
|
||||||
result=buf;
|
result=buf;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue