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

Fix SDSM encoding in CARMA Streets Plugin #571

Merged
merged 13 commits into from
Dec 18, 2023

Conversation

paulbourelly999
Copy link
Contributor

@paulbourelly999 paulbourelly999 commented Dec 16, 2023

PR Details

Description

Meant to fix encoding issues faced when attempting to encoded SDSM JSON messages sent from the SDSM service. Previous encoding logic was attempt to reduce the amount of raw pointers used in creating the SDSM message from the JSON payload by creating smart pointers instead. This logic was able to create seemly valid C Structs, inspected using asn print functions but encoding these would return errors similar to the one displayed below

To get functional encoding logic, this PR revert to using raw pointers and memory allocation

[2023-12-07 15:29:47.603] src/CARMAStreetsPlugin.cpp (691) - ERROR  : Failed to encoded SDSM message : 
{"msg_cnt":3,"source_id":"","equipment_type":1,"sdsm_time_stamp":{"second":641000,"minute":29,"hour":20,"day":7,"month":12,"year":2023,"offset":0},"ref_pos":{"long":0,"lat":0},"ref_pos_xy_conf":{"semi_major":0,"semi_minor":0,"orientation":0},"objects":[{"detected_object_data":{"detected_object_common_data":{"obj_type":0,"object_id":1,"obj_type_cfd":70,"measurement_time":0,"time_confidence":0,"pos":{"offset_x":-11,"offset_y":-20,"offset_z":-32},"pos_confidence":{"pos":32734,"elevation":1300573664},"speed":70,"speed_confidence":0,"speed_z":50,"heading":0,"heading_conf":0},"detected_object_optional_data":{"detected_obstacle_data":{"obst_size":{"width":5,"length":20,"height":10},"obst_size_confidence":{"width_confidence":0,"length_confidence":0}}}}}]}
Exception encountered: Unable to encode MessageFrame to bytes.

[2023-12-07 15:29:47.603] Utils/src/PluginClient.cpp (405) - ERROR  : CARMAStreetsPlugin terminating from unhandled exception: Segmentation fault
backtrace: (Hint: Use addr2line -C -e <exe> 0x#######) to find line number)
CARMAStreetsPlugin(+0x3e359) [0x55c14e2e0359]
/usr/local/lib/libasn_j2735_r63.so(OCTET_STRING_free+0xb5) [0x7f4e2ca3a1ba]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f4e2c278520]
/usr/local/lib/libasn_j2735_r63.so(OCTET_STRING_free+0xb5) [0x7f4e2ca3a1ba]
/usr/local/lib/libasn_j2735_r63.so(SEQUENCE_free+0x100) [0x7f4e2ca5964a]
CARMAStreetsPlugin(+0x37015) [0x55c14e2d9015]
CARMAStreetsPlugin(+0x1137c1) [0x55c14e3b57c1]
CARMAStreetsPlugin(+0xf67cb) [0x55c14e3987cb]
CARMAStreetsPlugin(+0xe6e68) [0x55c14e388e68]
CARMAStreetsPlugin(+0xdbe22) [0x55c14e37de22]
/lib/x86_64-linux-gnu/libboost_thread.so.1.74.0(+0x150cb) [0x7f4e2c9ac0cb]
/lib/x86_64-linux-gnu/libc.so.6(+0x94ac3) [0x7f4e2c2caac3]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x44) [0x7f4e2c35bbf4]
diagnostic info:
/home/V2X-Hub/src/tmx/TmxUtils/src/PluginExec.cpp(220): Throw in function HandleSignal
Dynamic exception type: tmx::utils::SignalException
std::exception::what: Segmentation fault

Related Issue

CDAR-585

Motivation and Context

Get working SDSM encoding logic

How Has This Been Tested?

Unit testing

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.

@paulbourelly999 paulbourelly999 marked this pull request as ready for review December 17, 2023 17:39
JsonToJ3224SDSMConverter converter;
std::string valid_json_str = R"(
{
"msg_cnt": 128,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The encoding error was this msg_cnt value out of range. Definition of this refer to: https://github.com/usdot-fhwa-stol/CARMASensitive/blob/b63ca0c26a68680ef575d2c995e2620d5068b006/J2735_201603_2023-06-22.asn#L3938

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah figured that out too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was not the cause of the initial errors though since it was failing with message count of 3

@dan-du-car dan-du-car merged commit ada57ac into develop Dec 18, 2023
7 of 8 checks passed
@dan-du-car dan-du-car deleted the fix/carma_streets_plugin_sdsm_encoding branch December 18, 2023 16:19
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.

2 participants