Skip to content

Commit

Permalink
Requested Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Byrdman32 committed Mar 18, 2024
1 parent 16f0047 commit 3c95302
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
8 changes: 1 addition & 7 deletions src/AutonomyLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
******************************************************************************/
namespace logging
{
extern rovecomm::RoveCommUDP* g_pRoveCommUDPNode;
extern rovecomm::RoveCommTCP* g_pRoveCommTCPNode;

/////////////////////////////////////////
// Forward declarations for namespace variables and objects.
/////////////////////////////////////////
Expand Down Expand Up @@ -163,13 +160,10 @@ namespace logging
stPacket.eDataType = manifest::Autonomy::TELEMETRY.find("CURRENTLOG")->second.DATA_TYPE;
stPacket.vData = StringToVector({formatted_log_message.data(), formatted_log_message.size()});

// Check if we should send packets to the SIM or board.
const char* cIPAddress = constants::MODE_SIM ? "127.0.0.1" : manifest::Autonomy::IP_ADDRESS.IP_STR.c_str();

// Send log command over RoveComm to BaseStation.
if (network::g_bRoveCommUDPStatus && network::g_bRoveCommTCPStatus)
{
network::g_pRoveCommUDPNode->SendUDPPacket(stPacket, cIPAddress, constants::ROVECOMM_OUTGOING_UDP_PORT);
network::g_pRoveCommUDPNode->SendUDPPacket(stPacket, "0.0.0.0", constants::ROVECOMM_OUTGOING_UDP_PORT);
}
}
} // namespace logging
18 changes: 5 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,32 +112,24 @@ int main()
network::g_pRoveCommUDPNode = new rovecomm::RoveCommUDP();
network::g_pRoveCommTCPNode = new rovecomm::RoveCommTCP();
// Start RoveComm instances bound on ports.
bool bRoveCommUDPInitSuccess = network::g_pRoveCommUDPNode->InitUDPSocket(manifest::General::ETHERNET_UDP_PORT);
bool bRoveCommTCPInitSuccess = network::g_pRoveCommTCPNode->InitTCPSocket(constants::ROVECOMM_TCP_INTERFACE_IP.c_str(), manifest::General::ETHERNET_TCP_PORT);
network::g_bRoveCommUDPStatus = network::g_pRoveCommUDPNode->InitUDPSocket(manifest::General::ETHERNET_UDP_PORT);
network::g_bRoveCommTCPStatus = network::g_pRoveCommTCPNode->InitTCPSocket(constants::ROVECOMM_TCP_INTERFACE_IP.c_str(), manifest::General::ETHERNET_TCP_PORT);
// Check if RoveComm was successfully initialized.
if (!bRoveCommUDPInitSuccess || !bRoveCommTCPInitSuccess)
if (!network::g_bRoveCommUDPStatus || !network::g_bRoveCommTCPStatus)
{
// Submit logger message.
LOG_CRITICAL(logging::g_qSharedLogger,
"RoveComm did not initialize properly! UDPNode Status: {}, TCPNode Status: {}",
bRoveCommUDPInitSuccess,
bRoveCommTCPInitSuccess);
network::g_bRoveCommUDPStatus,
network::g_bRoveCommTCPStatus);

// Since RoveComm is crucial, stop code.
bMainStop = true;

// Set RoveComm Status
network::g_bRoveCommUDPStatus = false;
network::g_bRoveCommTCPStatus = false;
}
else
{
// Submit logger message.
LOG_INFO(logging::g_qSharedLogger, "RoveComm UDP and TCP nodes successfully initialized.");

// Set RoveComm Status
network::g_bRoveCommUDPStatus = true;
network::g_bRoveCommTCPStatus = true;
}

// Initialize drivers.
Expand Down

0 comments on commit 3c95302

Please sign in to comment.