From 2935cb34497b403df462924ad882e98e5bc62821 Mon Sep 17 00:00:00 2001 From: Akram Date: Mon, 26 Aug 2024 10:29:24 +0200 Subject: [PATCH] Apply coding style corrections --- lib/APPReinforcementLearning/src/App.cpp | 16 +++++++++------- lib/APPReinforcementLearning/src/App.h | 6 +++--- lib/APPReinforcementLearning/src/ReadyState.cpp | 4 ++-- lib/APPReinforcementLearning/src/ReadyState.h | 4 ++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/APPReinforcementLearning/src/App.cpp b/lib/APPReinforcementLearning/src/App.cpp index d3e212a..9780d43 100644 --- a/lib/APPReinforcementLearning/src/App.cpp +++ b/lib/APPReinforcementLearning/src/App.cpp @@ -124,7 +124,7 @@ void App::loop() payload = {SMPChannelPayload::Status::DONE}; } - m_data_sent = m_smpServer.sendData(m_serialMuxProtChannelIdStatus, &payload, sizeof(payload)); + m_dataSent = m_smpServer.sendData(m_serialMuxProtChannelIdStatus, &payload, sizeof(payload)); m_statusTimer.restart(); } @@ -133,7 +133,7 @@ void App::loop() if (true == m_sendLineSensorsDataInterval.isTimeout() && (&DrivingState::getInstance() == m_systemStateMachine.getState())) { - sendLineSensorsData(); + m_dataSent = sendLineSensorsData(); m_sendLineSensorsDataInterval.restart(); } @@ -148,13 +148,13 @@ void App::loop() SMPChannelPayload::Mode payload = (1 == mode_options) ? SMPChannelPayload::Mode::DRIVING_MODE : SMPChannelPayload::Mode::TRAINING_MODE; - m_data_sent = m_smpServer.sendData(m_serialMuxProtChannelIdMode, &payload, sizeof(payload)); + m_dataSent = m_smpServer.sendData(m_serialMuxProtChannelIdMode, &payload, sizeof(payload)); m_modeSelectionSent = true; } } - if (false == m_data_sent) + if (false == m_dataSent) { /* Failed to send data to the supervisor. Go to error state. */ ErrorState::getInstance().setErrorMsg("DSF"); @@ -201,12 +201,13 @@ void App::handleRemoteCommand(const Command& cmd) * Private Methods *****************************************************************************/ -void App::sendLineSensorsData() +bool App::sendLineSensorsData() const { ILineSensors& lineSensors = Board::getInstance().getLineSensors(); uint8_t maxLineSensors = lineSensors.getNumLineSensors(); const uint16_t* lineSensorValues = lineSensors.getSensorValues(); uint8_t lineSensorIdx = 0U; + bool isDataSent = true; LineSensorData payload; if (LINE_SENSOR_CHANNEL_DLC == (maxLineSensors * sizeof(uint16_t))) @@ -219,8 +220,9 @@ void App::sendLineSensorsData() } } - /* Ignoring return value, as error handling is not available. */ - m_data_sent = m_smpServer.sendData(m_serialMuxProtChannelIdLineSensors, &payload, sizeof(payload)); + isDataSent = m_smpServer.sendData(m_serialMuxProtChannelIdLineSensors, &payload, sizeof(payload)); + + return isDataSent; } bool App::setupSerialMuxProt() diff --git a/lib/APPReinforcementLearning/src/App.h b/lib/APPReinforcementLearning/src/App.h index 846292d..c8dca20 100644 --- a/lib/APPReinforcementLearning/src/App.h +++ b/lib/APPReinforcementLearning/src/App.h @@ -73,7 +73,7 @@ class App m_statusTimer(), m_sendLineSensorsDataInterval(), m_modeSelectionSent(false), - m_data_sent(true), + m_dataSent(true), m_smpServer(Serial, this) { } @@ -143,7 +143,7 @@ class App bool m_modeSelectionSent; /** check if the data has been sent */ - bool m_data_sent; + bool m_dataSent; /** * Setup the SerialMuxProt channels. @@ -155,7 +155,7 @@ class App /** * Send line sensors data via SerialMuxProt. */ - void sendLineSensorsData(); + bool sendLineSensorsData() const; /** * Copy construction of an instance. diff --git a/lib/APPReinforcementLearning/src/ReadyState.cpp b/lib/APPReinforcementLearning/src/ReadyState.cpp index ec72007..1af2487 100644 --- a/lib/APPReinforcementLearning/src/ReadyState.cpp +++ b/lib/APPReinforcementLearning/src/ReadyState.cpp @@ -80,8 +80,8 @@ void ReadyState::entry() display.print(m_lapTime); display.print("ms"); } - m_stateTransitionTimer.start(m_state_Transition_period); - m_modeTimeoutTimer.start(mode_selected_period); + m_stateTransitionTimer.start(STATE_TRANSITION_PERIOD); + m_modeTimeoutTimer.start(MODE_SELECTED_PERIOD); m_mode = IDLE; m_isLastStartStopLineDetected = false; m_isButtonAPressed = false; diff --git a/lib/APPReinforcementLearning/src/ReadyState.h b/lib/APPReinforcementLearning/src/ReadyState.h index 6a778fc..5cef49e 100644 --- a/lib/APPReinforcementLearning/src/ReadyState.h +++ b/lib/APPReinforcementLearning/src/ReadyState.h @@ -117,10 +117,10 @@ class ReadyState : public IState }; /** Duration of the selected mode in ms. This is the maximum time to select a mode. */ - static const uint32_t mode_selected_period = 100; + static const uint32_t MODE_SELECTED_PERIOD = 100U; /** Duration to handle State changes in ms. */ - static const uint32_t m_state_Transition_period = 150; + static const uint32_t STATE_TRANSITION_PERIOD = 150U; /** * The line sensor threshold (normalized) used to detect the track.