Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-du-car committed Apr 12, 2024
2 parents 5ae22a4 + 9fef692 commit 50de700
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/v2i-hub/CARMACloudPlugin/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
},
{
"key":"CARMACloudIP",
"default":"http://0.0.0.0",
"description":"Server IP address for V2X hub"
"default":"http://127.0.0.1",
"description":"Server IP address of carma-cloud"
},
{
"key":"CARMACloudPort",
"default":"33333",
"description":"Server Port for V2X hub to receive TCM messages"
"description":"Server Port for V2X hub to send TCR messages to carma-cloud"
},
{
"key":"fetchTime",
Expand Down
23 changes: 15 additions & 8 deletions src/v2i-hub/CARMACloudPlugin/src/CARMACloudPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ void CARMACloudPlugin::CARMAResponseHandler(QHttpEngine::Socket *socket)
QByteArray st;
while(socket->bytesAvailable()>0)
{
PLOG(logDEBUG) << "Bytes available." << std::endl;
auto readBytes = socket->readAll();
st.append(readBytes);
}
Expand All @@ -219,11 +220,16 @@ void CARMACloudPlugin::CARMAResponseHandler(QHttpEngine::Socket *socket)
}
PLOG(logINFO) << "Received TCM bytes size: " << st.size()<< std::endl;

string tcm = "";
std::string tcm = "";
bool isCompressed = socket->headers().keys().contains(CONTENT_ENCODING_KEY) && std::string(socket->headers().constFind(CONTENT_ENCODING_KEY).value().data()) == CONTENT_ENCODING_VALUE;
if (isCompressed)
{
tcm = UncompressBytes(st).data();
QByteArray tcmBytes = UncompressBytes(st);
if(tcmBytes.size() == 0)
{
return;
}
tcm = tcmBytes.data();
}else{
tcm = st.data();
}
Expand All @@ -234,16 +240,17 @@ void CARMACloudPlugin::CARMAResponseHandler(QHttpEngine::Socket *socket)
tcm=updateTags(tcm,"TrafficControlParams","params");
tcm=updateTags(tcm,"TrafficControlGeometry","geometry");
tcm=updateTags(tcm,"TrafficControlPackage","package");
PLOG(logDEBUG2) << "Received TCM: " << tcm << std::endl;

std::list<std::string> tcm_sl = {};
std::list<std::string> tcmSL = {};
if (isCompressed)
{
tcm_sl = FilterTCMs(tcm);
tcmSL = FilterTCMs(tcm);
}else{
tcm_sl.push_back(tcm);
tcmSL.push_back(tcm);
}

for(const auto tcm_s: tcm_sl)
for(const auto tcm_s: tcmSL)
{
tsm5Message tsm5message;
tsm5EncodedMessage tsm5ENC;
Expand Down Expand Up @@ -625,10 +632,10 @@ QByteArray CARMACloudPlugin::UncompressBytes(const QByteArray compressedBytes) c
strm.avail_out = BUFFER_SIZE;
strm.next_out = (Byte *)buffer;
isDone = inflate(&strm, Z_NO_FLUSH);
outBuf.append(buffer, BUFFER_SIZE - strm.avail_out);
outBuf.append(buffer, BUFFER_SIZE - strm.avail_out);
} while (Z_STREAM_END != isDone); // Reach the end of stream to be uncompressed
}else{
PLOG(logWARNING) << "Error initalize stream. Err code = " << err << std::endl;
PLOG(logERROR) << "Error initalize stream. Err code = " << err << std::endl;
}
//Finished decompress data stream
inflateEnd(&strm);
Expand Down

0 comments on commit 50de700

Please sign in to comment.