diff --git a/module-cellular/Modem/GSM0710.cpp b/module-cellular/Modem/GSM0710.cpp index 2009c34d8..46c31625b 100644 --- a/module-cellular/Modem/GSM0710.cpp +++ b/module-cellular/Modem/GSM0710.cpp @@ -56,7 +56,7 @@ GSM0710Frame* GSM0710Buffer::GetCompleteFrame(GSM0710Frame* frame) { { if (frame != NULL) { - frame->channel = ((*local_readp & 252) >> 2); /*frame header address-byte read*/ + frame->channel = ((*readp & 252) >> 2); /*frame header address-byte read*/ if (frame->channel > vir_ports ) /* Field Sanity check if channel ID actually exists */ { LOG_WARN("Dropping frame: Corrupt! Channel Addr. field indicated %d, which does not exist",frame->channel); @@ -64,26 +64,26 @@ GSM0710Frame* GSM0710Buffer::GetCompleteFrame(GSM0710Frame* frame) { dropped_count++; goto update_buffer_dropping_frame; /* throw whole frame away, up until and incl. local_readp */ } - fcs = crcTable[fcs ^ *local_readp]; + fcs = crcTable[fcs ^ *readp]; Inc(); length_needed--; - frame->control = *local_readp; /*frame header type-byte read*/ - fcs = crcTable[fcs ^ *local_readp]; + frame->control = *readp; /*frame header type-byte read*/ + fcs = crcTable[fcs ^ *readp]; Inc(); length_needed--; - frame->length = (*local_readp & 254) >> 1; /*Frame header 1st length-byte read*/ - fcs = crcTable[fcs ^ *local_readp]; + frame->length = (*readp & 254) >> 1; /*Frame header 1st length-byte read*/ + fcs = crcTable[fcs ^ *readp]; } - if ((*local_readp & 1) == 0)/*if frame payload length byte extension bit not set, a 2nd length byte is in header*/ + if ((*readp & 1) == 0)/*if frame payload length byte extension bit not set, a 2nd length byte is in header*/ { //Current spec (version 7.1.0) states these kind of //frames to be invalid Long lost of sync might be //caused if we would expect a long frame because of an //error in length field. Inc(); - frame->length += (*local_readp*128); /*Frame header 2nd length-byte read*/ - fcs = crcTable[fcs^*local_readp]; + frame->length += (*readp*128); /*Frame header 2nd length-byte read*/ + fcs = crcTable[fcs^*readp]; } length_needed += frame->length; /*length_needed : 1 length byte + payload + 1 fcs byte + 1 end frame flag */ @@ -107,20 +107,20 @@ GSM0710Frame* GSM0710Buffer::GetCompleteFrame(GSM0710Frame* frame) { if (frame->length > 0) { { - end = endp - local_readp; + end = endp - readp; if (frame->length > end) /*wrap-around necessary*/ { - frame->data = local_readp; - local_readp = data + (frame->length - end); + frame->data = readp; + readp = data + (frame->length - end); local_datacount -= frame->length; } else { - frame->data = local_readp; - local_readp += frame->length; + frame->data = readp; + readp += frame->length; local_datacount -= frame->length; - if (local_readp == endp) - local_readp = data; + if (readp == endp) + readp = data; } if (GSM0710_FRAME_IS(MuxDefines ::GSM0710_TYPE_UI, frame)) { @@ -130,10 +130,10 @@ GSM0710Frame* GSM0710Buffer::GetCompleteFrame(GSM0710Frame* frame) { } } /*Okay, check FCS*/ - if (crcTable[fcs ^ (*local_readp)] != 0xCF) + if (crcTable[fcs ^ (*readp)] != 0xCF) { Inc(); - if (*local_readp != static_cast(MuxDefines ::GSM0710_FRAME_FLAG)) /* the FCS didn't match, but the next byte may not even be an end-frame-flag*/ + if (*readp != static_cast(MuxDefines ::GSM0710_FRAME_FLAG)) /* the FCS didn't match, but the next byte may not even be an end-frame-flag*/ { LOG_WARN("Dropping frame: Corrupt! End flag not present and FCS mismatch."); flag_found = 0; @@ -152,9 +152,9 @@ GSM0710Frame* GSM0710Buffer::GetCompleteFrame(GSM0710Frame* frame) { { /*Okay, check end flag */ Inc(); - if (*local_readp != static_cast(MuxDefines ::GSM0710_FRAME_FLAG)) + if (*readp != static_cast(MuxDefines ::GSM0710_FRAME_FLAG)) { - LOG_WARN("Dropping frame: End flag not present. Instead: %d", *local_readp); + LOG_WARN("Dropping frame: End flag not present. Instead: %d", *readp); flag_found = 0; dropped_count++; goto update_buffer_dropping_frame; diff --git a/module-cellular/Modem/InputSerialWorker.cpp b/module-cellular/Modem/InputSerialWorker.cpp index ac4de0def..a6bb572f0 100644 --- a/module-cellular/Modem/InputSerialWorker.cpp +++ b/module-cellular/Modem/InputSerialWorker.cpp @@ -185,9 +185,12 @@ int InputSerialWorker::ExtractFrames() { muxDaemon->channels[frame->channel].disc_ua_pending = 0; } } - if (frame->channel == muxDaemon->virtualPortsCount) - //TODO: M.P dunno what is this for ?? - // ql_cmux_debug = 0; + //TODO: M.P dunno what is this for ?? +#if 0 + if (frame->channel == muxDaemon->virtualPortsCount){ + ql_cmux_debug = 0; + } +#endif break; case MuxDefines::GSM0710_TYPE_DM: if (muxDaemon->channels[frame->channel].GetState() == MuxChannel::State::Opened) { @@ -246,10 +249,16 @@ int InputSerialWorker::ExtractFrames() { muxDaemon->WriteMuxFrame(frame->channel, NULL, 0, static_cast(MuxDefines::GSM0710_TYPE_UA) | static_cast(MuxDefines::GSM0710_PF)); - if (frame->channel == muxDaemon->virtualPortsCount) - //TODO: M.P dunno what is this for ?? - // ql_cmux_debug = 0; +//TODO: M.P dunno what is this for ?? +#if 0 + if (frame->channel == muxDaemon->virtualPortsCount){ + ql_cmux_debug = 0; + } +#endif break; + + default: + break; } } } diff --git a/module-cellular/Modem/MuxDaemon.cpp b/module-cellular/Modem/MuxDaemon.cpp index 6cd39bac8..e7e1aa139 100644 --- a/module-cellular/Modem/MuxDaemon.cpp +++ b/module-cellular/Modem/MuxDaemon.cpp @@ -84,8 +84,11 @@ int MuxDaemon::Start() { inSerialDataWorker->Init(); // Create virtual channels - for (uint32_t i = 0; i < virtualPortsCount; ++i) { - channels.push_back(MuxChannel(this,i)); + channels.push_back(MuxChannel(this,0,"ControlChannel")); + channels.push_back(MuxChannel(this,1,"NotificationChannel")); + + for (uint32_t i = 2; i < virtualPortsCount; ++i) { + channels.push_back(MuxChannel(this,i,("GenericChannel_" + std::to_string(i)).c_str())); } state = States::MUX_STATE_MUXING; diff --git a/module-cellular/Modem/MuxDaemon.hpp b/module-cellular/Modem/MuxDaemon.hpp index 47f94b593..dfb60a85e 100644 --- a/module-cellular/Modem/MuxDaemon.hpp +++ b/module-cellular/Modem/MuxDaemon.hpp @@ -106,7 +106,7 @@ private: cpp_freertos::MutexStandard serOutMutex; - uint32_t virtualPortsCount = 3; + uint32_t virtualPortsCount = 4; int uih_pf_bit_received = 0; diff --git a/source/main.cpp b/source/main.cpp index 1f46b16a5..1faa24da9 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -55,8 +55,8 @@ public: BlinkyService(const std::string& name) : sys::Service(name) { - timer_id = CreateTimer(1000,true); - ReloadTimer(timer_id); + timer_id = CreateTimer(5000,true); + //ReloadTimer(timer_id); muxdaemon = std::make_unique(); /* modem.reset();