Skip to content

Commit

Permalink
Update log level for Immediate Forward plugin msg (#686)
Browse files Browse the repository at this point in the history
<!-- Thanks for the contribution, this is awesome. -->

# PR Details
This PR drops the log level for a message size log. Since the log is not
providing any warning information, the level is dropped to DEBUG.

## Description

<!--- Describe your changes in detail -->

## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->

- [x] Defect fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that cause existing functionality
to change)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

- [ ] I have added any new packages to the sonar-scanner.properties file
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have read the **CONTRIBUTING** document.
[V2XHUB Contributing
Guide](https://github.com/usdot-fhwa-OPS/V2X-Hub/blob/develop/Contributing.md)
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
  • Loading branch information
paulbourelly999 authored Mar 10, 2025
2 parents 46e4cec + 48b931e commit 398c182
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions src/v2i-hub/ImmediateForwardPlugin/src/ImmediateForwardPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <boost/algorithm/hex.hpp>
#include "UdpClient.h"

using namespace boost::algorithm;
using namespace boost::algorithm;
using namespace boost::property_tree;
using namespace std;
using namespace tmx;
Expand Down Expand Up @@ -67,7 +67,7 @@ namespace ImmediateForward
else {
SendMessageToRadio(msg);
}


}

Expand Down Expand Up @@ -110,7 +110,7 @@ namespace ImmediateForward

}


void ImmediateForwardPlugin::SendMessageToRadio(IvpMessage *msg)
{
bool foundMessageType = false;
Expand All @@ -137,12 +137,11 @@ namespace ImmediateForward
for (int i = 0; i < (int)(strlen(msg->payload->valuestring)); i++)
msg->payload->valuestring[i] = toupper(msg->payload->valuestring[i]);

PLOG(logWARNING)<<_imfConfigs.size();
//loop through all MessageConfig and send to each with the proper TmxType
for (const auto &imfConfig: _imfConfigs)
{
{
for ( const auto &messageConfig: imfConfig.messages ) {

if (messageConfig.tmxType == msg->subtype)
{
foundMessageType = true;
Expand All @@ -154,42 +153,42 @@ namespace ImmediateForward

stringstream os;

/// if signing is Enabled, request signing with HSM
/// if signing is Enabled, request signing with HSM


if (imfConfig.enableHsm == 1)
{
std::string mType = messageConfig.sendType;
std::string mType = messageConfig.sendType;

std::for_each(mType.begin(), mType.end(), [](char & c){
c = ::tolower(c);
});
/* convert to hex array */

string msgString=msg->payload->valuestring;
string base64str="";
string base64str="";

hex2base64(msgString,base64str);
hex2base64(msgString,base64str);

std::string req = "\'{\"type\":\""+mType+"\",\"message\":\""+base64str+"\"}\'";



string cmd1="curl -X POST " + imfConfig.hsmUrl.value() + "sign" + " -H \'Content-Type: application/json\' -d "+req;
const char *cmd=cmd1.c_str();
string cmd1="curl -X POST " + imfConfig.hsmUrl.value() + "sign" + " -H \'Content-Type: application/json\' -d "+req;
const char *cmd=cmd1.c_str();
char buffer[2048];
std::string result="";
FILE* pipe= popen(cmd,"r");
FILE* pipe= popen(cmd,"r");

if (pipe == NULL )
if (pipe == NULL )
throw std::runtime_error("popen() failed!");
try{
while (fgets(buffer, sizeof(buffer),pipe) != NULL)
{
result+=buffer;
result+=buffer;
}
} catch (std::exception const & ex) {

pclose(pipe);
SetStatus<uint>(Key_SkippedSignError, ++_skippedSignErrorResponse);
PLOG(logERROR) << "Error parsing Messages: " << ex.what();
Expand All @@ -213,9 +212,9 @@ namespace ImmediateForward
base642hex(signedMsg,payloadbyte); // this allows sending hex of the signed message rather than base64

}
else
else
{
payloadbyte=msg->payload->valuestring;
payloadbyte=msg->payload->valuestring;
}
os << "Version=0.7" << "\n";
os << "Type=" << messageConfig.sendType << "\n" << "PSID=" << messageConfig.psid << "\n";
Expand All @@ -235,7 +234,7 @@ namespace ImmediateForward

auto &client = _udpClientMap.at(imfConfig.name);
client->Send(message);
PLOG(logDEBUG2) << _logPrefix << "Sending - TmxType: " << messageConfig.tmxType << ", SendType: " << messageConfig.sendType
PLOG(logDEBUG1) << _logPrefix << "Sending - TmxType: " << messageConfig.tmxType << ", SendType: " << messageConfig.sendType
<< ", PSID: " << messageConfig.psid << ", Client: " << client->GetAddress()
<< ", Channel: " << (messageConfig.channel.has_value() ? ::to_string( msg->dsrcMetadata->channel) : ::to_string(messageConfig.channel.value()))
<< ", Port: " << client->GetAddress();
Expand All @@ -260,4 +259,4 @@ namespace ImmediateForward
int main(int argc, char *argv[])
{
return run_plugin<ImmediateForward::ImmediateForwardPlugin>("Immediate Forward", argc, argv);
}
}

0 comments on commit 398c182

Please sign in to comment.