From db47284cdaa0bb4b01e6f76ba0c9304ee0d193c3 Mon Sep 17 00:00:00 2001 From: dev Date: Mon, 29 Jul 2024 19:02:23 -0400 Subject: [PATCH] Updates --- src/v2i-hub/SpatPlugin/README.md | 4 +++- src/v2i-hub/SpatPlugin/manifest.json | 17 +++++++++++------ src/v2i-hub/SpatPlugin/src/NTCIP1202.h | 1 - .../src/SignalControllerConnection.cpp | 6 ++++-- .../SpatPlugin/src/SignalControllerConnection.h | 2 +- src/v2i-hub/SpatPlugin/src/SpatPlugin.cpp | 9 ++++++--- src/v2i-hub/SpatPlugin/test/TestNTCIP1202.cpp | 1 + .../test/TestSignalControllerConnection.cpp | 2 +- 8 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/v2i-hub/SpatPlugin/README.md b/src/v2i-hub/SpatPlugin/README.md index 81a13c0f8..f106d1fb3 100644 --- a/src/v2i-hub/SpatPlugin/README.md +++ b/src/v2i-hub/SpatPlugin/README.md @@ -33,7 +33,9 @@ This plugin has several configuration parameters. Below these are listed out as **TSC_IP**: The IPv4 address of the destination Traffic Signal Controller (TSC). -**TSC_Remote_SNMP_Port**: The destination port on the Traffic Signal Controller (TSC) for SNMP NTCIP 1202 communication." +**TSC_SNMP_Port**: The destination port on the Traffic Signal Controller (TSC) for SNMP NTCIP 1202 communication." + +**TSC_SNMP_Community**: The SNMP Community used for sending SNMP NTCIP 1202 communication to Traffic Signal Controller (TSC). Please refer TSC vendor documentation for SNMP Community. **SPAT_Mode**: The format of received SPAT from Traffic Signal Controller (TSC). Acceptance values are BINARY and J2735_HEX. > [!NOTE] diff --git a/src/v2i-hub/SpatPlugin/manifest.json b/src/v2i-hub/SpatPlugin/manifest.json index 2ca547efa..1297658a9 100644 --- a/src/v2i-hub/SpatPlugin/manifest.json +++ b/src/v2i-hub/SpatPlugin/manifest.json @@ -30,23 +30,28 @@ }, { "key":"Local_IP", - "default":"", + "default":"127.0.0.1", "description":"The IPv4 address of the local computer for receiving Traffic Signal Controller Broadcast Messages." }, { "key":"Local_UDP_Port", - "default":"local port", + "default":"6053", "description":"The local UDP port for reception of Traffic Signal Controller Broadcast Messages from the TSC." }, { "key":"TSC_IP", - "default":"", + "default":"127.0.0.1", "description":"The IPv4 address of the destination Traffic Signal Controller (TSC)." }, { - "key":"TSC_Remote_SNMP_Port", - "default":"", - "description":"The destination port on the Traffic Signal Controller (TSC) for SNMP NTCIP communication." + "key":"TSC_SNMP_Port", + "default":"5050", + "description":"The destination port on the Traffic Signal Controller (TSC) for SNMP NTCIP 1202 communication." + }, + { + "key":"TSC_SNMP_Community", + "default":"public", + "description":"The SNMP Community used for sending SNMP NTCIP 1202 communication to Traffic Signal Controller (TSC). Please refer TSC vendor documentation for SNMP Community." }, { "key":"SPAT_Mode", diff --git a/src/v2i-hub/SpatPlugin/src/NTCIP1202.h b/src/v2i-hub/SpatPlugin/src/NTCIP1202.h index b92a12a26..2ebb279a8 100644 --- a/src/v2i-hub/SpatPlugin/src/NTCIP1202.h +++ b/src/v2i-hub/SpatPlugin/src/NTCIP1202.h @@ -30,7 +30,6 @@ #include #include #include -#include "carma-clock/carma_clock.h" using namespace std; diff --git a/src/v2i-hub/SpatPlugin/src/SignalControllerConnection.cpp b/src/v2i-hub/SpatPlugin/src/SignalControllerConnection.cpp index 32c4dcacd..431f5980f 100644 --- a/src/v2i-hub/SpatPlugin/src/SignalControllerConnection.cpp +++ b/src/v2i-hub/SpatPlugin/src/SignalControllerConnection.cpp @@ -17,14 +17,16 @@ namespace SpatPlugin { - SignalControllerConnection::SignalControllerConnection(const std::string &localIp, unsigned int localPort, const std::string &signalGroupMapping, const std::string &scIp, unsigned int scSNMPPort, const std::string &intersectionName, unsigned int intersectionId) : spatPacketReceiver(std::make_shared(localIp, localPort)) ,scSNMPClient(std::make_shared(scIp, scSNMPPort ,"administrator", "", "", "")), signalGroupMapping(signalGroupMapping), intersectionName(intersectionName), intersectionId(intersectionId) { + SignalControllerConnection::SignalControllerConnection(const std::string &localIp, unsigned int localPort, const std::string &signalGroupMapping, const std::string &scIp, unsigned int scSNMPPort, const std::string &scSNMPCommunity, const std::string &intersectionName, unsigned int intersectionId) : spatPacketReceiver(std::make_shared(localIp, localPort)) ,scSNMPClient(std::make_shared(scIp, scSNMPPort ,scSNMPCommunity, "", "", "")), signalGroupMapping(signalGroupMapping), intersectionName(intersectionName), intersectionId(intersectionId) { }; bool SignalControllerConnection::initializeSignalControllerConnection(bool enable_spat, bool set_intersection_id) const { // TODO : Update to more generic TSC Initialization process that simply follows NTCIP 1202 version guidelines. bool status = true; if (enable_spat) - { + { + // For binary SPAT a value of 2 enables original SPAT binary broadcast on the TSC and a value of 6 enables original SPAT plugin additional Pedestrian Information. + // NOTE: Pedestrian information is untested. tmx::utils::snmp_response_obj enable_spat; enable_spat.val_int = 2; enable_spat.type = tmx::utils::snmp_response_obj::response_type::INTEGER; diff --git a/src/v2i-hub/SpatPlugin/src/SignalControllerConnection.h b/src/v2i-hub/SpatPlugin/src/SignalControllerConnection.h index 2e70c6243..f207941a4 100644 --- a/src/v2i-hub/SpatPlugin/src/SignalControllerConnection.h +++ b/src/v2i-hub/SpatPlugin/src/SignalControllerConnection.h @@ -74,7 +74,7 @@ namespace SpatPlugin { * @param intersectionName Name of intersection * @param intersectionID Intersection ID. */ - SignalControllerConnection(const std::string &localIp, unsigned int localPort, const std::string &signalGroupMapping, const std::string &scIp, unsigned int scSNMPPort, const std::string &intersectionName, unsigned int intersectionID); + SignalControllerConnection(const std::string &localIp, unsigned int localPort, const std::string &signalGroupMapping, const std::string &scIp, unsigned int scSNMPPort, const std::string &scSNMPCommunity, const std::string &intersectionName, unsigned int intersectionID); /** * @brief Method attempts to send SNMP SET requests to initialize the TSC. NOTE: Some of the diff --git a/src/v2i-hub/SpatPlugin/src/SpatPlugin.cpp b/src/v2i-hub/SpatPlugin/src/SpatPlugin.cpp index e8c308ac0..c5067fc8b 100644 --- a/src/v2i-hub/SpatPlugin/src/SpatPlugin.cpp +++ b/src/v2i-hub/SpatPlugin/src/SpatPlugin.cpp @@ -38,22 +38,25 @@ namespace SpatPlugin { unsigned int port; std::string signal_controller_ip; unsigned int signal_controller_snmp_port; + std::string signal_controller_snmp_community; std::string intersection_name; unsigned int intersection_id; GetConfigValue("SignalGroupMapping", signal_group_mapping_json, &data_lock); GetConfigValue("Local_IP", ip_address, &data_lock); GetConfigValue("Local_UDP_Port", port, &data_lock); GetConfigValue("TSC_IP", signal_controller_ip, &data_lock); - GetConfigValue("TSC_Remote_SNMP_Port", signal_controller_snmp_port,&data_lock); + GetConfigValue("TSC_SNMP_Port", signal_controller_snmp_port,&data_lock); + GetConfigValue("TSC_SNMP_Community", signal_controller_snmp_community,&data_lock); + GetConfigValue("Intersection_Name", intersection_name,&data_lock); GetConfigValue("Intersection_Id", intersection_id, &data_lock); GetConfigValue("SPAT_Mode", spatMode, &data_lock); if (scConnection) { - scConnection.reset(new SignalControllerConnection(ip_address, port, signal_group_mapping_json, signal_controller_ip, signal_controller_snmp_port, intersection_name, intersection_id)); + scConnection.reset(new SignalControllerConnection(ip_address, port, signal_group_mapping_json, signal_controller_ip, signal_controller_snmp_port, signal_controller_snmp_community ,intersection_name, intersection_id)); } else { - scConnection = std::make_unique(ip_address, port, signal_group_mapping_json, signal_controller_ip, signal_controller_snmp_port, intersection_name, intersection_id); + scConnection = std::make_unique(ip_address, port, signal_group_mapping_json, signal_controller_ip, signal_controller_snmp_port,signal_controller_snmp_community, intersection_name, intersection_id); } // Only enable spat broadcast in simulation mode. TFHRC TSCs do not expose this OID so calls to it will fail in hardware deployment // Only set intersection ID in J2735_HEX SPAT Mode. Is only available for TSCs that support J2735 UPER HEX SPaT broadcast, which are all NTCIP 1202V3 or later. diff --git a/src/v2i-hub/SpatPlugin/test/TestNTCIP1202.cpp b/src/v2i-hub/SpatPlugin/test/TestNTCIP1202.cpp index 22d5f7486..ff30ba42a 100644 --- a/src/v2i-hub/SpatPlugin/test/TestNTCIP1202.cpp +++ b/src/v2i-hub/SpatPlugin/test/TestNTCIP1202.cpp @@ -16,6 +16,7 @@ #include #include #include +#include using namespace fwha_stol::lib::time; diff --git a/src/v2i-hub/SpatPlugin/test/TestSignalControllerConnection.cpp b/src/v2i-hub/SpatPlugin/test/TestSignalControllerConnection.cpp index e5b5aae34..e98be9c82 100644 --- a/src/v2i-hub/SpatPlugin/test/TestSignalControllerConnection.cpp +++ b/src/v2i-hub/SpatPlugin/test/TestSignalControllerConnection.cpp @@ -56,7 +56,7 @@ namespace SpatPlugin { ] } )"; - signalControllerConnection = std::make_unique("127.0.0.1", 5000, signalGroupMapping, "", 5020, "someIntersection", 9001); + signalControllerConnection = std::make_unique("127.0.0.1", 5000, signalGroupMapping, "", 5020,"administrator", "someIntersection", 9001); mockSnmpClient = std::make_shared("127.0.0.1", 6045, "administrator", "", "", ""); mockUdpServer = std::make_shared(); signalControllerConnection->scSNMPClient = mockSnmpClient;