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

Routable metadata #545

merged 6 commits into from
Jul 5, 2023

Conversation

jwillmartin
Copy link
Contributor

PR Details

Description

Adds PSID metadata to BSMs and SRMs that are sent to the Message Receiver plugin. If "RouteMessage" is enabled, the messages will be available for the Immediate Forward plugin to use.

Additional changes were made to build process to speed up process.

Related Issue

Motivation and Context

How Has This Been Tested?

Sent BSMs and SRMs to Message Receiver plugin. Messages were transmitted by Immediate Forward plugin when "RouteMessage" was enabled and not routed when disabled. Previously, messages were skipped or not routed, respectively.

Types of changes

  • 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:

  • 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.
  • I have read the CONTRIBUTING document.
    V2XHUB Contributing Guide
  • I have added tests to cover my changes.
  • All new and existing tests passed.

	modified:   src/build.sh
	modified:   src/v2i-hub/MessageReceiverPlugin/src/MessageReceiverPlugin.cpp
	modified:   src/v2i-hub/MessageReceiverPlugin/src/MessageReceiverPlugin.cpp
@@ -263,6 +263,7 @@ void MessageReceiverPlugin::OnMessageReceived(routeable_message &msg)
}

sendMsg = encode(encodedBsm, bsm);
msgPSID = 0x20;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do different messages have different msgPSID? Does a PSID ever change for a message type? I am not sure if we want to hardcode these values for different msgPSID?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These two I added were under the cases for BSMs and SRMs that are detected by the plugin. Others are kept at null.
If we want to add more messages to be routable, we can think about where to add their PSIDs. Right now it's added within the specific plugins that generate the messages.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have a enum or struct to consolidate all the PSID? Then use it here in this class? It might be easy to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't, but we could make one. What do you think about adding it here? https://github.com/usdot-fhwa-OPS/V2X-Hub/blob/develop/src/tmx/TmxApi/tmx/TmxApiMessages.h

Copy link
Collaborator

Choose a reason for hiding this comment

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

yep, I think that is a good location

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dan-du-car Changes made

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
Collaborator

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
Collaborator

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
Collaborator

@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
Collaborator

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

@@ -29,9 +29,9 @@
"description":"Port for the incoming message network connection."
},
{
"key":"RouteDSRC",
"key":"RouteMessage",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why renaming this boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only changing the user-facing name. Idea is to remove "DSRC" to avoid confusion with communication hardware used

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this boolean only for enable route for J2735Message? Some other internal v2xhub message like State, log on the UI are not controlled by this boolean? Maybe narrow down the Message to a specific type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, just here. It's specific to some logic for broadcasting messages received by this plugin.
I could change it to RouteJ2735

Copy link
Collaborator

Choose a reason for hiding this comment

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

make sense to me

@@ -280,6 +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 = 0xE0000016;
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a code smell on this line about an implicit conversion. Please check this out in the sonar scanner report.

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 Addressed

	modified:   src/tmx/TmxApi/tmx/TmxApiMessages.h
	modified:   src/v2i-hub/ImmediateForwardPlugin/src/ImmediateForwardPlugin.cpp
	modified:   src/v2i-hub/MessageReceiverPlugin/manifest.json
	modified:   src/v2i-hub/MessageReceiverPlugin/src/MessageReceiverPlugin.cpp
@@ -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

Copy link
Contributor

@paulbourelly999 paulbourelly999 left a comment

Choose a reason for hiding this comment

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

Looks good.

@paulbourelly999 paulbourelly999 merged commit 37eeb9b into develop Jul 5, 2023
8 checks passed
@paulbourelly999 paulbourelly999 deleted the routable-metadata branch July 5, 2023 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants