diff --git a/lib/channel/GwChannel.cpp b/lib/channel/GwChannel.cpp index 069b5ae..9c79983 100644 --- a/lib/channel/GwChannel.cpp +++ b/lib/channel/GwChannel.cpp @@ -58,8 +58,6 @@ GwChannel::GwChannel(GwLog *logger, this->name=name; this->sourceId=sourceId; this->maxSourceId=maxSourceId; - this->countIn=new GwCounter(String("count")+name+String("in")); - this->countOut=new GwCounter(String("count")+name+String("out")); this->impl=NULL; this->receiver=new GwChannelMessageReceiver(logger,this); this->actisenseReader=NULL; @@ -100,6 +98,12 @@ void GwChannel::begin( actisenseReader->SetReadStream(channelStream); } } + if (nmeaIn || readActisense){ + this->countIn=new GwCounter(String("count")+name+String("in")); + } + if (nmeaOut || seaSmartOut || writeActisense){ + this->countOut=new GwCounter(String("count")+name+String("out")); + } } void GwChannel::setImpl(GwChannelInterface *impl){ this->impl=impl; @@ -135,10 +139,10 @@ void GwChannel::updateCounter(const char *msg, bool out) } if (key[0] == 0) return; if (out){ - countOut->add(key); + if (countOut) countOut->add(key); } else{ - countIn->add(key); + if (countIn) countIn->add(key); } } @@ -209,7 +213,7 @@ void GwChannel::parseActisense(N2kHandler handler){ tN2kMsg N2kMsg; while (actisenseReader->GetMessageFromStream(N2kMsg)) { - countIn->add(String(N2kMsg.PGN)); + if(countIn) countIn->add(String(N2kMsg.PGN)); handler(N2kMsg,sourceId); } } @@ -220,7 +224,7 @@ void GwChannel::sendActisense(const tN2kMsg &msg, int sourceId){ //so we can check it here if (maxSourceId < 0 && this->sourceId == sourceId) return; if (sourceId >= this->sourceId && sourceId <= maxSourceId) return; - countOut->add(String(msg.PGN)); + if(countOut) countOut->add(String(msg.PGN)); msg.SendInActisenseFormat(channelStream); } diff --git a/lib/channel/GwChannelList.cpp b/lib/channel/GwChannelList.cpp index 9b68b07..b08bbfc 100644 --- a/lib/channel/GwChannelList.cpp +++ b/lib/channel/GwChannelList.cpp @@ -356,7 +356,7 @@ static GwChannel * createChannel(GwLog *logger, GwConfigHandler *config, int id, canRead, config->getString(param->readF), config->getString(param->writeF), - false, + config->getBool(param->sendSeasmart), config->getBool(param->toN2K), config->getBool(param->readAct), config->getBool(param->writeAct));