Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routable metadata #545

Merged
merged 6 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions ext/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
# exit on errors
set -e

# Find number of cores available
numCPU=$(nproc)

# An OPENAPI based Qt webservice is needed by the plugins for http requests processing. A custom generated code using OPENAPI framework is located in GitHub.
pushd /tmp
QHTTPENGINE_VERSION=1.0.1
wget -O qhttpengine-${QHTTPENGINE_VERSION}.tar.gz https://github.com/nitroshare/qhttpengine/archive/refs/tags/${QHTTPENGINE_VERSION}.tar.gz
tar xvf qhttpengine-${QHTTPENGINE_VERSION}.tar.gz
cd qhttpengine-${QHTTPENGINE_VERSION}/
cmake .
make
make -j${numCPU}
make install
popd

Expand All @@ -20,7 +23,7 @@ wget -O date-${DATELIB_VERSION}.tar.gz https://github.com/HowardHinnant/date/arc
tar xvf date-${DATELIB_VERSION}.tar.gz
cd date-${DATELIB_VERSION}/
cmake .
make
make -j${numCPU}
make install
popd

Expand All @@ -29,19 +32,19 @@ ldconfig
# Server for the Qt webservice
pushd server
cmake .
make
make -j${numCPU}
make install
popd

pushd ccserver
cmake .
make
make -j${numCPU}
make install
popd

pushd pdclient
cmake .
make
make -j${numCPU}
make install
popd

Expand All @@ -50,6 +53,6 @@ pushd /tmp
git clone https://github.com/ckgt/NemaTode.git
cd NemaTode
cmake .
make
make -j${numCPU}
make install
popd
3 changes: 3 additions & 0 deletions scripts/install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ LIBRARY_DEPENDENCIES=" \
# install all things needed for deployment, always done
apt-get install -y $DEPENDENCIES ${LIBRARY_DEPENDENCIES}

numCPU=$(nproc)

# install gtest
cd /usr/src/googletest/
mkdir -p build/
cd build
cmake ..
make -j${numCPU}
make install
5 changes: 4 additions & 1 deletion src/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ set -e
# script executes all tmx and v2i build and coverage steps so that they can be singularly
# wrapped by the sonarcloud build-wrapper

numCPU=$(nproc)

RELEASE_BUILD=0
if [ "$1" = "release" ]; then
RELEASE_BUILD=1
Expand All @@ -36,14 +38,15 @@ fi
pushd tmx
cmake -Bbuild -DCMAKE_PREFIX_PATH=\"/usr/local/share/tmx\;\/opt/carma/cmake\;\" -DCMAKE_CXX_FLAGS="${COVERAGE_FLAGS}" -DCMAKE_C_FLAGS="${COVERAGE_FLAGS}" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" .
pushd build
make
make -j${numCPU}
make install
popd
popd

pushd v2i-hub
cmake -Bbuild -DCMAKE_PREFIX_PATH=\"/usr/local/share/tmx\;\/opt/carma/cmake\;\" -DqserverPedestrian_DIR=/usr/local/share/qserverPedestrian/cmake -Dv2xhubWebAPI_DIR=/usr/local/share/v2xhubWebAPI/cmake/ -DCMAKE_CXX_FLAGS="${COVERAGE_FLAGS}" -DCMAKE_C_FLAGS="${COVERAGE_FLAGS}" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" .
pushd build
make -j${numCPU}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this ${numCPU}? Whese is this env variable from?

Copy link
Contributor Author

@jwillmartin jwillmartin Jun 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The env is for using the number of cores available on the local machine. This allows for building in parallel. Since we're using Ubuntu as the docker image, this command to get the env variable will always work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a link explain how this command "make -j${numCPU}" allow building in parallel. Sorry, I have not seen this before and am curious how this works. Also if we are running this inside a base image ubuntu, how does that get the host machine hardware specs, like num of CPUs?

Copy link
Contributor Author

@jwillmartin jwillmartin Jun 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Section 5.4 here: https://www.gnu.org/software/make/manual/make.html#Parallel
or run: make --help and you'll see a short description there

Yeah, it's still linked to the host machine, so it's able to find the number of cores available. Then this would run one job per core.

Copy link
Contributor

@dan-du-car dan-du-car Jun 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, in section 5.4: If there is nothing looking like an integer after the ‘-j’ option, there is no limit on the number of job slots.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, numCPU set by numproc

make install
popd
popd
4 changes: 2 additions & 2 deletions src/tmx/TmxApi/tmx/IvpMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ typedef unsigned int IvpMsgFlags;
#define IvpMsgFlags_RouteDSRC 0x01

typedef struct IvpDsrcMetadata {
int channel;
int psid;
int channel;
} IvpDsrcMetadata;

typedef struct IvpMessage {
Expand Down Expand Up @@ -64,7 +64,7 @@ typedef enum {
*/
IvpMessage *ivpMsg_create(const char *type, const char *subtype, const char *encoding, IvpMsgFlags flags, cJSON *payload);

IvpMessage *ivpMsg_addDsrcMetadata(IvpMessage *msg, int channel, int psid);
IvpMessage *ivpMsg_addDsrcMetadata(IvpMessage *msg, int psid, int channel);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we reversed these and can we ensure this does not have any unintentional impacts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paulbourelly999 Did it to match the changes made here:
https://github.com/usdot-fhwa-OPS/V2X-Hub/pull/433/files#diff-ea7aa329ba2d3d9e2dbe5e75039c3eadbb3886943f4596c9e0fbacb5e8af8b0c

Did some quick tests with SPaT, MAP, PSM, and TIM to make sure they were still getting the right PSIDs set


/*!
* Creates a new IvpMessage from a json string.
Expand Down
51 changes: 50 additions & 1 deletion src/tmx/TmxApi/tmx/TmxApiMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,56 @@ static CONSTEXPR const char *STATUS_STARTED_STRING = "Started, waiting for conne
static CONSTEXPR const char *STATUS_RUNNING_STRING = "Running";
static CONSTEXPR const char *STATUS_STALE_STRING = "Connection going stale";
static CONSTEXPR const char *STATUS_STOPPED_STRING = "Stopped / Disconnected";


enum msgPSID
{
None_PSID = 0x00,
mapData_PSID = 0x8002,
signalPhaseAndTimingMessage_PSID = 0x8002,
basicSafetyMessage_PSID = 0x20,
commonSafetyRequest_PSID = 0x20,
emergencyVehicleAlert_PSID = 0x8005,
intersectionCollision_PSID = 0x8002,
nmeaCorrections_PSID = 0x8000,
probeDataManagement_PSID = 0x8004,
probeVehicleData_PSID = 0x8004,
roadSideAlert_PSID = 0x8003,
rtcmCorrections_PSID = 0x8000,
signalRequestMessage_PSID = 0xE0000016,
signalStatusMessage_PSID = 0x8002,
travelerInformation_PSID = 0x8003,
personalSafetyMessage_PSID = 0x27,
testMessage00_PSID = 0xBFEE,
testMessage01_PSID = 0xBFEE,
testMessage02_PSID = 0xBFEE,
testMessage03_PSID = 0xBFEE,
testMessage04_PSID = 0x8003,
testMessage05_PSID = 0x8003
};

static CONSTEXPR const char *MSGPSID_NONE_PSID_STRING = "None";
static CONSTEXPR const char *MSGPSID_MAPDATA_PSID_STRING = "0x8002";
static CONSTEXPR const char *MSGPSID_SIGNALPHASEANDTIMINGMESSAGE_PSID_STRING = "0x8002";
static CONSTEXPR const char *MSGPSID_BASICSAFETYMESSAGE_PSID_STRING = "0x20";
static CONSTEXPR const char *MSGPSID_COMMONSAFETYREQUEST_PSID_STRING = "0x20";
static CONSTEXPR const char *MSGPSID_EMERGENCYVEHICLEALERT_PSID_STRING = "0x8005";
static CONSTEXPR const char *MSGPSID_INTERSECTIONCOLLISION_PSID_STRING = "0x8002";
static CONSTEXPR const char *MSGPSID_NMEACORRECTIONS_PSID_STRING = "0x8000";
static CONSTEXPR const char *MSGPSID_PROBEDATAMANAGEMENT_PSID_STRING = "0x8004";
static CONSTEXPR const char *MSGPSID_PROBEVEHICLEDATA_PSID_STRING = "0x8004";
static CONSTEXPR const char *MSGPSID_ROADSIDEALERT_PSID_STRING = "0x8003";
static CONSTEXPR const char *MSGPSID_RTCMCORRECTIONS_PSID_STRING = "0x8000";
static CONSTEXPR const char *MSGPSID_SIGNALREQUESTMESSAGE_PSID_STRING = "0xE0000016";
static CONSTEXPR const char *MSGPSID_SIGNALSTATUSMESSAGE_PSID_STRING = "0x8002";
static CONSTEXPR const char *MSGPSID_TRAVELERINFORMATION_PSID_STRING = "0x8003";
static CONSTEXPR const char *MSGPSID_PERSONALSAFETYMESSAGE_PSID_STRING = "0x27";
static CONSTEXPR const char *MSGPSID_TESTMESSAGE00_PSID_STRING = "0xBFEE";
static CONSTEXPR const char *MSGPSID_TESTMESSAGE01_PSID_STRING = "0xBFEE";
static CONSTEXPR const char *MSGPSID_TESTMESSAGE02_PSID_STRING = "0xBFEE";
static CONSTEXPR const char *MSGPSID_TESTMESSAGE03_PSID_STRING = "0xBFEE";
static CONSTEXPR const char *MSGPSID_TESTMESSAGE04_PSID_STRING = "0x8003";
static CONSTEXPR const char *MSGPSID_TESTMESSAGE05_PSID_STRING = "0x8003";

} /* End namespace api */

} /* End namespace messages */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ void ImmediateForwardPlugin::SendMessageToRadio(IvpMessage *msg)
if (!foundMessageType)
{
SetStatus<uint>(Key_SkippedNoMessageRoute, ++_skippedNoMessageRoute);
PLOG(logWARNING)<<" WARNINNG TMX Subtype not found in configuration. Message Ignored: " <<
PLOG(logWARNING)<<" WARNING TMX Subtype not found in configuration. Message Ignored: " <<
"Type: " << msg->type << ", Subtype: " << msg->subtype;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/v2i-hub/MessageReceiverPlugin/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"description":"Port for the incoming message network connection."
},
{
"key":"RouteDSRC",
"key":"RouteJ2735",
"default":"false",
"description":"Set the flag to route a received J2735 message."
"description":"Set the flag to route/broadcast a received J2735 message to TMX Core."
},
{
"key":"EnableSimulatedBSM",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void MessageReceiverPlugin::OnMessageReceived(routeable_message &msg)
BsmEncodedMessage encodedBsm;
SrmEncodedMessage encodedSrm;


int msgPSID = api::msgPSID::None_PSID;

if (msg.get_type() == "Unknown" && msg.get_subtype() == "Unknown")
{
Expand Down Expand Up @@ -263,6 +263,7 @@ void MessageReceiverPlugin::OnMessageReceived(routeable_message &msg)
}

sendMsg = encode(encodedBsm, bsm);
msgPSID = api::msgPSID::basicSafetyMessage_PSID;
if (!simBSM) return;
}
break;
Expand All @@ -280,7 +281,7 @@ void MessageReceiverPlugin::OnMessageReceived(routeable_message &msg)
ntohl(*((uint32_t*)&(bytes.data()[24]))),
ntohl(*((uint32_t*)&(bytes.data()[28]))));
sendMsg = encode(encodedSrm, srm);

msgPSID = api::msgPSID::signalRequestMessage_PSID;
}
break;
default:
Expand Down Expand Up @@ -330,6 +331,7 @@ void MessageReceiverPlugin::OnMessageReceived(routeable_message &msg)
if (routeDsrc)
{
sendMsg->set_flags(IvpMsgFlags_RouteDSRC);
sendMsg->addDsrcMetadata(msgPSID);
}
else
{
Expand All @@ -345,7 +347,7 @@ void MessageReceiverPlugin::UpdateConfigSettings()
lock_guard<mutex> lock(syncLock);

// Atomic flags
GetConfigValue("RouteDSRC", routeDsrc);
GetConfigValue("RouteJ2735", routeDsrc);
GetConfigValue("EnableSimulatedBSM", simBSM);
GetConfigValue("EnableSimulatedSRM", simSRM);
GetConfigValue("EnableSimulatedLocation", simLoc);
Expand Down Expand Up @@ -465,7 +467,6 @@ int MessageReceiverPlugin::Main()
SetStatus<uint>(Key_SkippedSignVerifyError, ++_skippedSignVerifyErrorResponse);
PLOG(logERROR) << "Error parsing Messages: " << ex.what();
continue;
;
}
PLOG(logDEBUG1) << "SCMS Contain response = " << result << std::endl;
cJSON *root = cJSON_Parse(result.c_str());
Expand Down